Duration 9:47

Efficient Exponentiation

114 264 watched
0
5.1 K
Published 1 May 2021

How many multiplys does it take to compute x^n? It may be fewer than you think! Worried that calling x ** 15 "slow" is not correct? Don't worry, I tested! In[4]: timeit.timeit("100000 ** 15") Out[4]: 0.3686526000000043 In[5]: timeit.timeit("pow_15_minimal(100000)", globals=globals()) Out[5]: 0.3275107000000048 ― mCoding with James Murphy (https://mcoding.io ) Source code: https://github.com/mCodingLLC/VideosSampleCode Project Euler: https://projecteuler.net/problem= 122 Addition Chains: https://graal.ens-lyon.fr/~ yrobert/algo/additionchains1.pdf Compiler Explorer: https://godbolt.org/z/qeG1e3jdP SUPPORT ME ⭐ --------------------------------------------------- Patreon: https://patreon.com/mCoding Paypal: https://www.paypal.com/donate/?hosted_button_id=VJY5SLZ8BJHEE Other donations: https://mcoding.io/donate BE ACTIVE IN MY COMMUNITY 😄 --------------------------------------------------- Discord: https://discord.gg/Ye9yJtZQuN Github: https://github.com/mCodingLLC/ Reddit: https://www.reddit.com/r/mCoding/ Facebook: https://www.facebook.com/james.mcoding

Category

Show more

Comments - 278