Factorial



Factorial value is Multiply the number from 1 to n continuously.



Example-1:


Input    : n = 5
Output   : 120    
Explain  : 1*2*3*4*5 = 120. Multiply the number from 1 to 5.


Example-2:


Input    : n = 4
Output   : 24  
Explain  : 1*2*3*4 = 24. Multiply the number from 1 to 4.   







Solution




public class Main
{
    public static void main(String [] args)
    {
        int n = 5;

        long fact = 1;

        for(int i = 1; i <= n; i++) 
        {
            fact = fact*i;
        }

        System.out.print(fact);      
    }
}
n = 5

k = 1

for i in range(1,n+1):

    k *= i

print(k)



Output



120