intclimbStairs(intn) { inta = 1, b = 2; intc = 0; if(n == 1)returna; if(n == 2)returnb; for(inti = 2; i < n; ++i) { c = a + b; a = b; b = c; } returnc; }
The Permanent URL is: Coding Exercise – Climbing Stairs – Fibonacci Numbers – C++ – Online Judge Related posts: How to Implement Integer Square Root in C/C++? Question: Implement integer square root for int sqrt(int x) There are many ways to compute the... SteemJs: How Many Witnesses...