- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecursivePow.java
More file actions
Latest commit
24 lines (20 loc) · 570 Bytes
/
Copy pathrecursivePow.java
File metadata and controls
24 lines (20 loc) · 570 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
importjava.util.Scanner;
publicclassrecursivePow {
staticintpower(intbase,intpow){
if(pow == 0){
return1;
}else{
returnpower(base, pow-1)*base;
}
}
publicstaticvoidmain(String[] args) {
intbase,exp;
Scannerinp = newScanner(System.in);
System.out.println("enter base:");
base = inp.nextInt();
System.out.println("enter exponent:");
exp = inp.nextInt();
System.out.println(power(base, exp));
inp.close();
}
}