ClavinJune

math materi CP

Oct 7th, 2018
149
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def pow(a,b):
  2.   if b == 0: return 1
  3.   if b % 2 == 0:
  4.     x = pow(a, b/2)
  5.     return x * x
  6.   else:
  7.     return f(a,b-1) * a
  8. # pow O(lg(n))
  9. ##################################################################
  10. '''
  11. kpk => kalikan semua angka pangkat terkecil
  12. fpb => kalikan angka paling kecil yang sama dengan pangkat terbesar
  13.  
  14. a * b == fpb(a,b) * kpk(a,b)
  15.  
  16. fpb(20, 35) == fpb(20, 35%20)
  17. fpb(20, 15) == fpb(5, 15)
  18. fpb(5, 0) == 5
  19.  
  20. fpb(a, b):
  21.  return fpb(b, a%b)
  22.  
  23. kpk(a, b) == a*b / fpb(a,b)
  24. MINDBLOOOWWNN
  25.  
  26. using memoization for Combination
  27. '''
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×