Click Here To Follow our Telegram Channel for more such news and amazing free stuffs.

  Telegram Channel  - https://t.me/codexelltech


import java.util.Scanner;
class Fact_Recursion

{
    public static void main(String args[])
    {
        Scanner f = new Scanner(System.in);
       
        System.out.println("Enter the number:");
       
        int num = f.nextInt();
        int factorial=fact(num);
        System.out.println("Factorial of the given number is= " +factorial);
     }
     static int fact(int n)
    {
        int output;
        if(n==1)
        {
            return 1;
        }
        output = fact(n-1)*n;
        return output;
    }
}

Output:
Enter the number:
5
Factorial of the number is = 120

Click Here To Follow our Telegram Channel for more such news and amazing free stuffs.

  Telegram Channel  - https://t.me/codexelltech

Click here to visit www.codexell.tech for more such references.
Previous Post Next Post