import java.io.*;
class Power
{
public static boolean isPerfectPower(int num)
{
for(int i = 2; i <= num; i++)
{
for(int j = 2; j <= num; j++)
{
if(Math.pow(i, j) == num)
{
return true;
}
else if(Math.pow(i, j) > num)
break;
}
}
return false;
}
public static void main(String args[])throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the number: ");
int num = Integer.parseInt(br.readLine());
boolean status = true;
if(!isPerfectPower(num))
{
int n = num;
int pf = 2;
while(n != 1)
{
if(n % pf == 0)
{
int s = pf * pf;
if(num % s != 0)
{
status = false;
break;
}
n /= pf;
}
else
pf++;
}
}
else
status = false;
if(status)
System.out.println(num + " is an Achilles Number.");
else
System.out.println(num + " is not an Achilles Number.");
}
}
No comments:
Post a Comment
any problem in any program comment:-