yabovbel

k_lab3

Jun 2nd, 2022
715
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. print("0 < B <= A")
  2. a=int(input("A: "))
  3. b=int(input("B: "))
  4. g=1
  5. print("НОД({0}:{1})=".format(a, b))
  6. while(a%2==0 and b%2==0):
  7.     a//=2
  8.     b//=2
  9.     g*=2
  10.     print("={0}*НОД({1}:{2})=".format(g, a, b))
  11. while(a!=0):
  12.     if(a%2==0):
  13.         a//=2
  14.     if(b%2==0):
  15.         b//=2
  16.     if(a>=b):
  17.         a-=b
  18.     else:
  19.         b-=a
  20.     print("={0}*НОД({1}:{2})=".format(g, a, b))
  21. print("={0}".format(g*b))
  22.    
  23.  
  24.  
Advertisement
Add Comment
Please, Sign In to add comment