MCPcopy Create free account
hub / github.com/apna-college/Alpha / calcSum

Method calcSum

7_RecursionBasics/RecursionBasics.java:29–36  ·  view source on GitHub ↗
(int n)

Source from the content-addressed store, hash-verified

27 }
28
29 public static int calcSum(int n) {
30 if(n == 1) {
31 return 1;
32 }
33 int Snm1 = calcSum(n-1);
34 int Sn = n + Snm1;
35 return Sn;
36 }
37
38 //calculate nth term in fibonacci
39 public static int fib(int n) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected