anjha
BAN USER
Comments (2)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
public class recursiveQtn {
public recursiveQtn() {
super();
}
public static void main(String[] args) {
//recursiveQtn recursiveQtn = new recursiveQtn();
int min;
min = new Integer(args[0]).intValue();
int max;
max = new Integer(args[1]).intValue();
if (min>max)
System.out.println("Min cannot be more than max");
recursiveQtn mobj = new recursiveQtn();
System.out.println(mobj.sum(min,max));
}
public int sum ( int min , int max )
{ if ( min == max )
return min;
else
return max + sum (min , max-1 );
}
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
If (N > m) then
- anjha March 10, 2016If X < N then 0
If X > mN then 0
else number of ways = F ( (X-N)mod m +1 )
-- where F(n) is nth term of fibonacci sequence .
Else if (N <= m)
If X < N then 0
If X > mN then 0
else number of ways = (X-N+1)!/ ( (X-2N+2)! *N!)