-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgcd.py
More file actions
30 lines (26 loc) · 765 Bytes
/
gcd.py
File metadata and controls
30 lines (26 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def gcdRecurse( a , b ):
'''
objective: to calculate GCD of 2 numbers
parameters: a -> first number
b ->second number
return value: gcd of two numbers
'''
#approach : using division algorithm recursively
if b == 0:
return a
else:
return gcdRecurse( b , a % b )
def main():
'''
objective: to calculate GCD of 2 numbers
input values: x -> first number
y ->second number
result: gcd of two numbers
'''
#approach : using function gcdRecurse
x = int(input('Enter first number : '))
y = int(input('Enter second number : '))
print(' GCD of given numbers is : ' , gcdRecurse( x , y ))
if __name__ == '__main__':
main()
print('End of program')