class power
{
static double power(double x,int n)
{
if(n>1)
return x*power(x,n-1);
}
public static void main(String[] args)
{
System.out.println("5 is to power 5 is :" + power.power(5.0,5));
}
class power
{
double n=0;
static double power(double x,double n)
{
if(n>1)
n=x*power(x,n-1);
return n;
}
public static void main(String[] args)
{
System.out.println("5 is to power 5 is :" + power.power(5.0,5.0));
}
class power
{
double n=0;
static double power(double x,double n)
{
if(n>1)
n=x*power(x,n-1);
return n;
}
public static void main(String[] args)
{
System.out.println("5 is to power 5 is :" + power.power(5.0,5.0));
}
class power
{
static double power(double x,int n)
{
if(n>1)
return x*power(x,n-1);
else
return x; \\这里缺少一个返回值,要不然N=1时,函数没有返回值。
}
public static void main(String[] args)
{
System.out.println("5 is to power 5 is :" + power.power(5.0,5));
}