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

Method factorial

java/Chapter 17/Question17_3/QuestionB.java:16–24  ·  view source on GitHub ↗
(int num)

Source from the content-addressed store, hash-verified

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

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected