Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/purvgwtw/public_html/tutorials/common.php on line 7
Java Factorial Program
Sponsered Links
Categories
Sponsered Links

Java Factorial Program

Through the given code, we are finding the factorial of the specifed number.

import java.util.*;
class FactorialExample{
public static void main(String []args){
Scanner input=new Scanner(System.in);
System.out.print("Enter Number:");
int num=input.nextInt();
long fac=num;
for(int i=num;i>1;i--)
{
fac=fac*(i-1);
}
System.out.println(fac);
}
}

Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2014 PURVACOMPUTERS.COM All Right Reserved