MCPcopy Create free account
hub / github.com/careercup/ctci / factorial

Method factorial

java/Chapter 17/Question17_3/QuestionA.java:21–29  ·  view source on GitHub ↗
(int num)

Source from the content-addressed store, hash-verified

19 }
20
21 public static int factorial(int num) {
22 if (num == 1) {
23 return 1;
24 } else if (num > 1) {
25 return num * factorial(num - 1);
26 } else {
27 return -1; // Error
28 }
29 }
30
31 public static void main(String[] args) {
32 for (int i = 1; i < 12; i++) {

Callers 2

mainMethod · 0.95
test_permutationsMethod · 0.45

Calls

no outgoing calls

Tested by 1

test_permutationsMethod · 0.36