factorial with java

Write a Java program to find the factorial of a given number (using loop)

Let’s see how to write a Java program to find the factorial of a given number (using loop). Java program to find factorial class Factorial{ public static void main(String args[]){int i; long fact=1;int number=10;//It is the number whose factorial is calculated, modify it if needed for(i=1;i<=number;i++){fact=fact*i;System.out.println(“printing from inside loop:”+fact);} System.out.println(“Factorial of “+number+” is: “+fact);}}

Scroll to top
error: physicsTeacher.in