- 2
What is the Algorithm?
What's the Algorithm for cube root and square root and pow? Any one can help me?
4 Answers
+ 1
POW: variable * variable
SQRT: read on this: https://www.quora.com/Are-there-any-methods-to-calculate-the-square-and-cube-root-of-a-number-faster?top_ans=131742412
+ 1
For power you can simply multiply the number power times
For square root and cube root you can use binary search or Newton's method
0
HungryTradie the ** operator in C++ is interpreted as double de-reference, not exponent.
- 2
G'day ABUBAKAR ALHOMIDY What math could you use?
edit: yep, I was wrong! This is for Python not in C++
(For pow could you substitute:
var**num
For root could you use:
var**(1/num)
Maybe that is too simple, maybe I'm just wrong....)