Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.18 KB | None | 0 0
  1. #input
  2. a=int(input ("a="));
  3. b=int(input ("b="));
  4. #main
  5. c=a;
  6. d=b;
  7. while c!=d: #輾轉相除法
  8. if c<d:
  9. d=d-c;
  10. if c>d:
  11. c=c-d;
  12.  
  13. lcm=a*b/c;
  14. print ('hcf= %d;lcm= %d' % (c,lcm));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement