+ 1
Write a recursive mathematical definition for computing 2 lifted to power n for a positive integer n
help me to solve this
10 Respostas
+ 5
Please share your attempt while seeking help. All we want to see is whether you tried or not.
+ 2
thx a lot Martin Taylor đ€ you just helped me with the next problem đđ€
+ 1
I think that's lifted and not lefted. Probably a power method is all he looking for.
+ 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);
}
}
+ 1
that's the last code i tried it.. hope you get what i mean
+ 1
it finally worked correctly thank you so much Avinesh I've been working on it for hours đ
0
Just return 1 instead of 0.
0
Habo Osman you're welcome
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