Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Recursive Functions
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Christian Bau, post: 1684439"] double power (double x, unsigned long n) { if (n == 0) { return 1.0; } else { double result = x; unsigned long k = 1; while (2*k <= n) k *= 2; while (k > 1) { k /= 2; result *= (n & k) ? result * x : result; } return result; } } But your example is much more difficult because the execution time of a single multiplication depends on the size of the numbers involved, so it is not the number of operations that counts, but their cost. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Recursive Functions
Top