You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
public static double function(double x,int n){
|
|
if(x==0)
|
|
{
|
|
return 0.0;
|
|
}
|
|
if(n>0)
|
|
{
|
|
return Pow(x,n);
|
|
}
|
|
else
|
|
{
|
|
return 1/Pow(x,-n);
|
|
}
|
|
}
|
|
public static double Pow(double x,int n){
|
|
if(n==0)
|
|
return 1;
|
|
double tem=Pow(x,n/2);
|
|
if(n%2==0)
|
|
{
|
|
return tem*tem;
|
|
}
|
|
else{
|
|
return tem*tem*x;
|
|
}
|
|
}
|