Skip to content

Instantly share code, notes, and snippets.

@Nikolay995
Created April 2, 2018 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nikolay995/6c87969a929d91663edff00c3d9ca354 to your computer and use it in GitHub Desktop.
Save Nikolay995/6c87969a929d91663edff00c3d9ca354 to your computer and use it in GitHub Desktop.
The simplest factorial algorithm in Java
public class FindFactorial {
public static void main(String[] args) {
System.out.println(factorial(5));
}
private static int factorial(int x){
return (x == 1 ? 1 : x*factorial(x-1));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment