Hallo zusammen ,
zu meiner Aufgabe : Ich habe 2 Arrays gegeben . 1. Array enthalt die Basis und 2. Array das Exponent . Mein Problem ist Math.pow darf nicht benutzt werden. Es soll so aussehen : 1^1, 2^2,3^3,4^4.
Mein Code:
class pow {
public static void main(String[] args) {
int basis[]={1,2,3,4};//Basis
int exp []={1,2,3,4};//Exponent
double d ;
d = pow(basis, exp);
}
static double pow(int x[],int n[]){
int i,j ;
double p=1;
for (i=0;i<x.length;i++) {
p = Math.pow(x, n); //this without Math.pow
System.out.println(p);
}
return p;
}
zu meiner Aufgabe : Ich habe 2 Arrays gegeben . 1. Array enthalt die Basis und 2. Array das Exponent . Mein Problem ist Math.pow darf nicht benutzt werden. Es soll so aussehen : 1^1, 2^2,3^3,4^4.
Mein Code:
class pow {
public static void main(String[] args) {
int basis[]={1,2,3,4};//Basis
int exp []={1,2,3,4};//Exponent
double d ;
d = pow(basis, exp);
}
static double pow(int x[],int n[]){
int i,j ;
double p=1;
for (i=0;i<x.length;i++) {
p = Math.pow(x, n); //this without Math.pow
System.out.println(p);
}
return p;
}