Method that invokes themselves (recursion)

class testfactorial
public static void main (String[] args)
for ( int i =0;i<9; i++)
System.out.println(“f(“+i+”) = “+f(i));
try {;}
catch (Exception e) {}
static long f(int n)
if (n<2) return 1;
return n*f(n-1);



Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.