Program : Find Out Factorial of a Number using Scanner Class in JAVA - Java2021 : Online Tutorials Hub

Java2021 : Online Tutorials Hub

JAVA | Advance Java | MySQL | Data Structure | Git | HTML | CSS | JS

Latest

Post Top Ad

Program : Find Out Factorial of a Number using Scanner Class in JAVA

Write a program a to find a factorial number in Java
import java.util.Scanner;
public class FactorialNumber {
    public static void main(String[] args) {
        int number;
        int fact=1;
        System.out.println("enter the number");
        Scanner scanner=new Scanner(System.in);
        number=scanner.nextInt();
        for (int i=1;i<=number;i++)
        {
            fact=fact*i;
        }
        System.out.println("Factorial of Number "+fact);
    }

}
Output : 






Start with your Choice

-Important Programs for Freshers

Sorting and Searching Programs
Learn Pattern Programs 
Click to learn Array Programs
Click to Learn MySQL 
for any complaint regarding my Blog please visit contact us page and write what problem you have!

No comments:

Pages