Count-ways-reach-nth-stair-using-step-1-2
Code:
public class Main{
static int fib(int n)
{
if(n<=1)
return n;
return fib(n-1)+fib(n-2);
}
static int ways(int n)
{
return fib(n+1);
}
public static void main(String[] args) {
System.out.println("count-ways-reach-nth-stair-using-step-1-2:"+ways(8));
}
}
Output: count-ways-reach-nth-stair-using-step-1-2:8
count-ways-reach-nth-stair-using-step-1-2:8
Comments
Post a Comment