MCPcopy Create free account
hub / github.com/chaharnishant11/CodeIn10DSA / power

Class power

Recursion/Code/powerOf2.java:2–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1import java.util.*;
2class power
3 {
4
5 static int power(int n)
6 {
7 if(n==1) // base condition;
8 return 2;
9
10 int recResult = power(n-1);
11 int smallCal = 2*recResult;
12
13 return smallCal;
14 }
15
16 // Driver Code
17 public static void main(String args[])
18 {
19 Scanner in = new Scanner(System.in);
20 System.out.print("Enter a positive number : ");
21 int n = in.nextInt();
22
23 System.out.println("Factorial of " + n + " is " + power(n));
24 }
25}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected