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

Method fib

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

Source from the content-addressed store, hash-verified

37
38 //calculate nth term in fibonacci
39 public static int fib(int n) {
40 if(n == 0 || n == 1) {
41 return n;
42 }
43 int fnm1 = fib(n-1);
44 int fnm2 = fib(n-2);
45 int fn = fnm1 + fnm2;
46 return fn;
47 }
48
49 public static boolean isSorted(int arr[], int i) {
50 if(i == arr.length-1) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected