+ 1

# Write a recursive mathematical definition for computing 2 lifted to power n for a positive integer n

help me to solve this

21st Mar 2021, 6:09 PM
Habo Osman
+ 5
Please share your attempt while seeking help. All we want to see is whether you tried or not.
21st Mar 2021, 6:19 PM
Avinesh
+ 2
thx a lot Martin Taylor ðŸ–¤ you just helped me with the next problem ðŸ˜‚ðŸ–¤
22nd Mar 2021, 3:25 AM
Habo Osman
+ 1
I think that's lifted and not lefted. Probably a power method is all he looking for.
21st Mar 2021, 6:28 PM
Avinesh
+ 1
import java.util.Scanner ; public class TestMax{ public static void main(String[] args) { Scanner input = new Scanner (System.in ); System.out.println("Enter a non negative number to be the power of 2" ); int power = input.nextInt (); System.out.println ("result = " + xMethod (power)) ; } public static int xMethod(int power) { if (power < 0) return 0 ; else return 2*xMethod(power-1); } }
21st Mar 2021, 6:55 PM
Habo Osman
+ 1
that's the last code i tried it.. hope you get what i mean
21st Mar 2021, 6:56 PM
Habo Osman
21st Mar 2021, 7:03 PM
Habo Osman
+ 1
it finally worked correctly thank you so much Avinesh I've been working on it for hours ðŸ˜­
21st Mar 2021, 7:10 PM
Habo Osman
0
Just return 1 instead of 0.
21st Mar 2021, 7:07 PM
Avinesh
0
Habo Osman you're welcome
21st Mar 2021, 7:15 PM
Avinesh
0
"Write a recursive mathematical definition...â€œ Iâ€˜m not sure why you all are writing code? That does not seem to be whatâ€˜s asked. a_0 = 1 a_n = 2*a_{n-1} , n>=1
22nd Mar 2021, 5:22 AM
John Doe