Created
April 2, 2018 16:08
-
-
Save Nikolay995/6c87969a929d91663edff00c3d9ca354 to your computer and use it in GitHub Desktop.
The simplest factorial algorithm in Java
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
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