Source code
import java.util.Scanner;
class FactorialProgram
{
public void fact ()
{
int i, fact = 1;
Scanner Sc = new Scanner (System.in);
System.out.println ("Enter any number to find it's Factorial");
int number = Sc.nextInt ();
for (i = 1; i <= number; i++)
{
fact = fact * i;
}
System.out.println ("Factorial of " + number + " is: " + fact);
}
}
class Main{
public static void main (String args[]){
FactorialProgramobj = new FactorialProgram
();
obj.fact ();
}
}
you have created such a nice blog which helped me alot.
ReplyDelete