Factorial Program in Java

Google Advertisements

Prev Tutorial Next Tutorial

Java Program to Find Factorial on Number

Factorial of any number is the product of an integer and all the integers below it for example factorial of 4 is 4! = 4 * 3 * 2 * 1 = 24. In below code i will show you how to design Java program to find factorial, using for loop you can perform this task.

Factorial Program in Java

import java.util.Scanner;
class Factorial
	public static void main(String[] args) 
    int no, fect=1;
	Scanner s=new Scanner(System.in);
    System.out.println("Enter any number :");
    for(int i=1; i<=no; i++)
	System.out.println("Factorial is :" +fect);


Enter any number :
Factorial is :

Syntax to compile and run java program


for compile -> c:/>javac Factorial.java
for run -> c:/>java Factorial

Explnation of Code

  • Scanner s=new Scanner(System.in): are used for receive input from keyboard.
  • nextInt(): method are used for get integer type value from keyboard.
  • System.out.println("....."): are used for display message on screen or console.

Prev Tutorial Next Tutorial

Google Advertisements

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 8076671483

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. Cloud Computing Tutorial

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects. Download Java C C++ Projects

Download Projects

Adsense Advertisements

Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: hitesh.xc@gmail.com or 8076671483 Try this Keyword C++ Programs