Loading, please wait...

A to Z Full Forms and Acronyms

Factorial Program using Java

Jul 07, 2018 int, String, for, DataInputStream, 1797 Views
This Program is used to calculate the Factorial of Given Number.
import java.io.*; 
class da 
{ 
public static void main(String arg[]) throws IOException 
{ 
DataInputStream d = new DataInputStream(System.in); 
int i,n,f; 
String s; 
f=1; 
System.out.print("enter the number : "); 
s = d.readLine(); 
n = Integer.parseInt(s); 
for(i=1;i<=n;i++) 
{ 
f = f * i; 
} 
System.out.println("\n"+"factorial of given number "+n+" is : " +f); 
} 
}
A to Z Full Forms and Acronyms

Related Article