7 ms·
There are efficient ways to compute x^n. Eg. you want to compute x^8. Instead of multiplying x eight times by itself, you can do ((x^2)^2)^2, which is just thre
by jasamer 4y ago
There are efficient ways to compute x^n. Eg. you want to compute x^8. Instead of multiplying x eight times by itself, you can do ((x^2)^2)^2, which is just three multiplications.
To be fair, I’m not sure whether similar optimizations exist for computing the factorial, but I don’t think so.
- adgjlsfhk1 4y agothere aren't similar tricks for factorials.