MCPcopy Create free account
hub / github.com/careercup/CtCI-6th-Edition / Example

Class Example

Java/Big O/Example_16/Example.java:3–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1package Example_16;
2
3public class Example {
4
5 public static int powersOf2(int n) {
6 if (n < 1) {
7 return 0;
8 } else if (n == 1) {
9 System.out.println(1);
10 return 1;
11 } else {
12 int prev = powersOf2(n / 2);
13 int curr = prev * 2;
14 System.out.println(curr);
15 return curr;
16 }
17 }
18
19 public static void main(String[] args) {
20 powersOf2(4);
21 }
22
23}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected