You are viewing a single comment's thread. Return to all comments →
That's because math.pow() will use floating-point numbers. It is more typically used when the power is a real number, not (necessarily) an integer.
math.pow()
To raise integers to an integer power, use the exponentiation operator **:
**
third = second**2 + first
(Of course to compute a square of x, x*x works just fine as well.)
x
x*x
Seems like cookies are disabled on this browser, please enable them to open this website
Fibonacci Modified
You are viewing a single comment's thread. Return to all comments →
That's because
math.pow()
will use floating-point numbers. It is more typically used when the power is a real number, not (necessarily) an integer.To raise integers to an integer power, use the exponentiation operator
**
:(Of course to compute a square of
x
,x*x
works just fine as well.)