import java.util.*;
class Power
{
public static void main(String args[])
{
int x,y,n;
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number:");
x=sc.nextInt();
n=sc.nextInt();
y=pow(x,n);
System.out.println("Ans="+y);
}
static int pow (int n)
{
if(n==1)
return x;
else
return (x*pow(x,n-1));
}
}
class Power
{
public static void main(String args[])
{
int x,y,n;
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number:");
x=sc.nextInt();
n=sc.nextInt();
y=pow(x,n);
System.out.println("Ans="+y);
}
static int pow (int n)
{
if(n==1)
return x;
else
return (x*pow(x,n-1));
}
}
No comments :
Post a Comment