Last active
December 26, 2015 13:29
-
-
Save joeyv/7158381 to your computer and use it in GitHub Desktop.
Calculates factorial of a number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Factorial { | |
public static void main(String[] args) { | |
int total = 1; | |
int i, num; | |
Scanner scan = new Scanner(System.in); | |
num = scan.nextInt(); | |
for( i = num; i >= 1; i-- ){ | |
total *= i; | |
} | |
System.out.print (num + " factorial is: " + total); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment