As a newbie programmer

Let's get GCD @ Dcoder

Dcoder icon

Problem: Cody was doing his maths homework, suddenly he found a GCD(Greatest Comman divisor) problem. He is very lazy to do all the calculations for this exercise, so he just took his mobile and opened the Dcoder App, decided to code a program to find solution to GCD problem. You have to help him making this program, where you are presented with 2 integers, and you have to find their Greatest Comman Divisor.

The HCF or GCD of two integers is the largest integer that can exactly divide both numbers (without a remainder).

Input: Input contains 2 integers n1 and n2 separated by a newline.

Output: Print the GCD of n1 and n2

Constraints: 1≤n1,n2≤1000

Sample Input: 54

24

Sample Output: 

6

from math import gcd
print(gcd(int(input()), int(input())))

How do you rate this article?

0


Lochard
Lochard

20240228 Arrived in the UK for about 2 week. All my fears persist. Some are even getting worse. https://github.com/locharp/asylum_diary/


As a newbie programmer
As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets

Publish0x Publish0x

Reward the author with $0.01 in crypto, and earn yourself as you read!

20% to author / 80% to me.
Rewards are FREE. Publish0x pays them, not you.

Page not displaying correctly?