Friday 8 May 2015

Print the factorial any number in JAVA

package array;

import java.util.Scanner;

public class Fact {


public static void main(String[] args) {
int i,n,f=1;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number");
n=sc.nextInt();
for(i=1;i<=n;i++)
{
f=f*i;
}
System.out.println("Factorial is");
System.out.println(f);

}

}

1 comment:

  1. Wow! It was the best article , actually you have posted something useful than others, because I read many articles related to this basics of programming, but I only get impressed with your post only, keep posting.
    Regards,
    Python Training in Chennai|Python Training|Python Training Institutes in Chennai

    ReplyDelete