| 1 | import java.util.*; |
| 2 | class 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected