-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFYLab1Quest3.py
More file actions
31 lines (22 loc) · 858 Bytes
/
Copy pathFYLab1Quest3.py
File metadata and controls
31 lines (22 loc) · 858 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
31
# a. Write a function that takes two positive integer and returns GCD which is found by
# Consecutive Integer Checking Algorithm.
# b. Using your function write a program that prompts the user to enter two positive integer
# and displays the GCD of them.
# Sample Run:
# Non-negative first integer >=2 please: 64
# Non-negative first integer >=2 please: 12
# greatest common divisor: 4
import time
start = time.clock()
# =========================================
def gcd(number1, number2):
if number2 == 0:
return number1
return gcd(number2, number1 % number2)
# =========================================
number1 = int(input("Non-negative first integer >=2): "))
number2 = int(input("Non-negative first integer >=2): "))
answer = gcd(number1, number2)
print("greatest common divisor: ", answer)
end = time.clock()
print(end - start)