Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

2 V2 - X 2

Answered: 1 week ago

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago