:toll:hdi hat gesagt.:Ich glaub Math is aber immer verfügbar ???:L
public class Bla {
public static void main(String[] args) {
System.out.println(Math.pow(2, 2));
}
}
hdi hat gesagt.:Willst du mich anmachen oder was :wink:
x := a; y := b; z := 1;
while y > 0 do
begin
if odd(y) then z := z*x;
y := y div 2;
x := x*x;
end;
IceTi hat gesagt.:Ne funzt nicht, Math hab ich importiert... habe keine Main Funktion,da es ein Midlet ist...
public static double pow(double x, double y){
return (y>0) ? power(x, y) : 1/power(x, -y);
}
private static double power(double x, double y){
if ( y == 0){
return 1;
}
if(y%2 == 0){
return power(x*x , y/2);
} else{
return x * power(x , y-1);
}
}}