fork(1) download
  1. def b_gcd(m, n):
  2. fact = 1
  3.  
  4. while m > 1 and n > 1 and m != n:
  5.  
  6. om, on = m & 1, n & 1
  7.  
  8. if om and on:
  9. m, n = abs(m - n)>>1, min(m, n)
  10.  
  11. elif not (om or on):
  12. fact, m, n = fact<<1, m>>1, n>>1
  13.  
  14. else:
  15. m, n = (m>>1, n) if on else (m, n>>1)
  16.  
  17. m, n = (m, n) if n > m else (n, m)
  18. return (m or n)<<(fact - 1)
Success #stdin #stdout 0.04s 9488KB
stdin
Standard input is empty
stdout
Standard output is empty