Click the Twitter icon to follow our tweets and
know more about us.

Find factorial using recursion

class factorial
{
   public static void main(int n)
   {
       int f=fact(n);
       System.out.println(f);
    }
    public static int fact(int n)
    {
        int f=1;
        if(n==1)
        return 1;
        else
        {
            f=f*n;
            f=f*fact(n-1);
            return f;
        }
    }
}

Comments (0)

Post a Comment