Write a program to find factorial of number in java

 Write a program to find factorial of number in java

public class Factorial
{
    public static void main(String args[]){
        int number = 5 ,fact=1;
        for(int i=1;i<=number;i++){
            fact=fact*i;
            }
        System.out.println("Factorial of "+number+" is "+fact);
    }
}

Output
Factorial of 5 is 120

Comments

Popular posts from this blog

Make a GST Calculator using HTML and JavaScript

How to make simple bill maker by using python tkinter

Write a program to find the sum of 1/2+4/3+5/6+8/7+9/10 using loop in java