Question
class raisePowerr { public static int power(int base, int pow) { if(pow==2) { return base*base; } else if(pow%2!=0) { return base*power(base*base, pow/2); } else {
class raisePowerr { public static int power(int base, int pow) { if(pow==2) { return base*base; } else if(pow%2!=0) { return base*power(base*base, pow/2); } else { return power(base*base, pow/2); } } } public static void main(String[] args) { int ans1 = power(2,8); System.out.println("2**8=" + ans1); int ans2 = power(2,10); System.out.println("2**10=" + ans2); int ans3 = power(3,18); System.out.println("3**18=" + ans3); int ans4 = power(4,9); System.out.println("4**9=" + ans4); } }
i keep getting a {raisePowerr.java:26: error: class, interface, or enum expected} error please help
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started