Created
January 12, 2016 15:09
-
-
Save Yur-ok/46b2746d7c8c2bad80b7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package Lesson3.KeyPoint5; | |
/** | |
* Created by Юрий on 12.01.2016. | |
*/ | |
public class Factorial { | |
public static void main(String[] args) { | |
System.out.println(factorial(5)); | |
System.out.println(factorial(1)); | |
System.out.println(factorial(3)); | |
} | |
static long factorial(int i) { | |
int count = i; | |
long total = 1; | |
for (int j = 1; count > 0; j++) { | |
total *= j; | |
count--; | |
} | |
return total; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment