Advertisement
HasteBin0

Python Greatest Common Divisor (Fast)

Sep 3rd, 2019 (edited)
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. num_a = int(input('Enter first positive integer: '))
  2. num_b = int(input('Enter second positive integer: '))
  3.  
  4. while num_a != num_b:
  5.     if num_a > num_b:
  6.         num_a -= num_b
  7.     else:
  8.         num_b -= num_a
  9.  
  10. input ('GCD is %d' % num_a)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement