Skip to content

Instantly share code, notes, and snippets.

@thmain
Created June 2, 2018 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thmain/33f2e9a7ee6c36e3168b97de80feb13e to your computer and use it in GitHub Desktop.
Save thmain/33f2e9a7ee6c36e3168b97de80feb13e to your computer and use it in GitHub Desktop.
public class FactorialRecursion {
public static int factorial(int num){
if(num==0)
return 1;
return num * factorial(num-1);
}
public static void main(String[] args) {
int num = 10;
int fact = factorial(num);
System.out.println("Factorial of a number: " + num + " is(Recursion): " + fact);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment