Efficient Exponentiation

Published: 01 May 2021
on channel: mCoding
118,785
5.1k

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/VideosS...
Project Euler: https://projecteuler.net/problem=122
Addition Chains: https://graal.ens-lyon.fr/~yrobert/al...
Compiler Explorer: https://godbolt.org/z/qeG1e3jdP

SUPPORT ME ⭐
---------------------------------------------------
Patreon:   / mcoding  
Paypal: https://www.paypal.com/donate/?hosted...
Other donations: https://mcoding.io/donate

BE ACTIVE IN MY COMMUNITY 😄
---------------------------------------------------
Discord:   / discord  
Github: https://github.com/mCodingLLC/
Reddit:   / mcoding  
Facebook:   / james.mcoding  


On this page of the site you can watch the video online Efficient Exponentiation with a duration of hours minute second in good quality, which was uploaded by the user mCoding 01 May 2021, share the link with friends and acquaintances, this video has already been watched 118,785 times on youtube and it was liked by 5.1 thousand viewers. Enjoy your viewing!