You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Farrukh Ahmad edited this page Dec 15, 2015
·
1 revision
A simple a very common use of recursion to make a product of 0 * 1 * 2 * .....*n series
for example 5 = 5 * 4 * 3 * 2 * 1 = 120
public static void main(String args[])
{
int n = 6;
System.out.println(facto(n));
}
static int facto(int n)
{
if (n==0 ) return 1;
if (n==1) return 1;
return n*facto(n-1);
}
}