0

I am trying to figure out how many ways you can go if you only take one or two steps. For example. If the number is 4 there are 5 ways you can move going one or two steps.

I have to do it with recursion.

I have the following code:

```
public class Ex16
{
public static int numWaysToClimb(int n)
{
if (n==0)
return 0;
if (n==1)
return 1;
return numWaysToClimb(n-1,n-2);
}
public static int numWaysToClimb(int x, int y)
{
if ((x==0)||(y==0))
return 0;
if ((x==1)||(y==1))
return 1;
return (numWaysToClimb(x-1,y-2)+numWaysToClimb(x-2,y-1));
}
}
```

When I give it 4 it answers me two. I am guessing my problem is in the base cases in the second method.

Any help will be appreciated.