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

Method power

7_RecursionBasics/RecursionBasics.java:84–93  ·  view source on GitHub ↗
(int x, int n)

Source from the content-addressed store, hash-verified

82 }
83
84 public static int power(int x, int n) {
85 if(n == 0) {
86 return 1;
87 }
88 // int xnm1 = power(x, n-1);
89 // int xn = x * xnm1;
90 // return xn;
91
92 return x * power(x, n-1);
93 }
94
95 public static int optimizedPower(int x, int n) {
96 if(n == 0) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected