Recursion

Factorial by Recursion

import java.util.*; 
class Factorial
{
 static int no;
 public static void main(String [] args)
 {
    System.out.print("Enter Number Which Is Greater Then Zero : " );
  Scanner sc = new Scanner(System.in);
    no = sc.nextInt();
    int fact = factorial(no);
    System.out.println("Factorial is : " + fact);    
 }

 static int factorial(int i)
 {
    if(i <= 1)
    {
     return i;
    }
  
    else
    {
     i = i * factorial(i-1);
     return i;
    }
 }
}