Base Exponent program in Java


public class Rec
{
public static double power(double base, int exponent)
{
if(exponent>0)
{
return (base*power(base,exponent-1));
}
else if(exponent<0 data-blogger-escaped-br=""> {
exponent=-exponent;
return 1/(base*power(base,exponent-1));
}
else
{
return 1;
}
}
public static void main(String args [])
{
System.out.println(power(2,-3));
}
}

Comments

Popular posts from this blog

GL_QUAD_STRIP Example In OpenGl

GL_POLYGON Example In OpenGl