Created
January 4, 2016 01:30
-
-
Save mindwing/a7ef486a92015db43b30 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
/** | |
* Created by mindwing on 2016-01-04. | |
*/ | |
public class FactorialTest { | |
static int factorial(int f) { | |
if (f == 0) { | |
return 1; | |
} else { | |
return f * factorial(f - 1); | |
} | |
} | |
public static void main(String[] args) { | |
System.out.println("5! = " + factorial(5)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment