Write a Program To find Factorial of a number ,By taking user input value in java

Factorial.java

import java.util.Scanner;
 class Factorial
 {
     public static void main(String args[]) {
 int n,fact=1;
    Scanner sc=new Scanner(System.in);
    System.out.print("Enter the number:");
    n=sc.nextInt();
 for(int i=1;i<=n;i++)
    {
    fact=fact*i;    
 }
    System.out.print("Factorial of" +n+ "is" +fact);
 }
 }

You may also like...

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x