fork(1) download
  1. a=24
  2. b=36
  3.  
  4. def hcf(a,b):
  5. if a<=b:
  6. g=a
  7. else:
  8. g=b
  9. j=1
  10. t=2
  11.  
  12. while True:
  13. if a%t==0 and b%t==0 :
  14. j=j*t
  15. a=a//t
  16. b=b//t
  17. t=2
  18. else:
  19. t=t+1
  20. if t==g :
  21. return j #j*a*b for lcm
  22.  
  23. print(hcf(a,b))
Success #stdin #stdout 0.03s 9652KB
stdin
Standard input is empty
stdout
12