int steps_combi(int steps)
{
if(steps==1)
return 1;
if(steps==2)
return 2;
// can take single step or double step
return (steps_combi(steps-1) + steps_combi(steps-2));
}
You have to consider permutations as well and not just combinations.This will increase the total number of ways.~VishalOn 1/23/06, Ankur Khetrapal
[EMAIL PROTECTED] wrote:
thisis done using integral solution method..
letx - no. of single steps
lety - no of double steps
x + 2y = 22
x = 22 - 2y
Hi,
It can be derived as follows...
Let f(n) denote the no. of ways in which 'n' steps can be climbed...
So, for climbing 'n' steps, the possible combinations are,
1. Climb one step initially.. so, n-1 steps left.. they can be climbed
in f(n-1) ways, OR
2. Climb 2 steps initally... so, n-2