|
|
|
|
|
by koblenski
4686 days ago
|
|
That is a closed form expression, but it is not O(1) unless the processor can raise a number (an inexact floating point number, no less) to a power in constant time. The closed form expression is still O(n) because of multiplication, and the result isn't an exact number unless the constants are run out to enough precision for the value of n that is being computed. |
|
Also, depending on how you are accounting for the 'size of n', the iterative algorithm has time O(2^b) where b is the number of bits required to represent n and the closed form is O(b).