Skip to content

Instantly share code, notes, and snippets.

@w3farid
Created March 4, 2016 04:59
Show Gist options
  • Save w3farid/5698efa762dd56a8267a to your computer and use it in GitHub Desktop.
Save w3farid/5698efa762dd56a8267a to your computer and use it in GitHub Desktop.
Calculate Factorial Value of a number?
import java.util.Scanner;
public final class Factorial {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
System.out.println("Check Factorial number: ");
int a=s.nextInt();
int fc=1;
int i=1;
while (i<=a) {
fc *=i;
i++;
}
System.out.println("Factorial Number is: "+fc);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment