Skip to content

Instantly share code, notes, and snippets.

@Yur-ok
Created January 12, 2016 15:09
Show Gist options
  • Save Yur-ok/46b2746d7c8c2bad80b7 to your computer and use it in GitHub Desktop.
Save Yur-ok/46b2746d7c8c2bad80b7 to your computer and use it in GitHub Desktop.
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