Java program to find factorial of a number

import java.util.Scanner;
class Factorial
   public static void main(String args[])
      int n, c, fact = 1;
      System.out.println("Enter an integer to calculate it's factorial");
      Scanner in = new Scanner(;
      n = in.nextInt();
      if ( n < 0 )
         System.out.println("Number should be non-negative.");
         for ( c = 1 ; c <= n ; c++ )
            fact = fact*c;
         System.out.println("Factorial of "+n+" is = "+fact);

Output :

Share Your Comments
Previous Java program to check number is palindrome or not
Next Online Banking Project PHP

About author

Aamir Shaikh
Aamir Shaikh 1705 posts

<p>A Blogger, SEO Analyst and passionate Web Developer from India.<br /> Believes in hard work and continues working to achieve success.</p>

View all posts by this author →

You might also like