An **Achilles Number** is a number that is powerful but not a perfect power.

A **Powerful Number** is a positive integer N, such that for every prime factor p of N, p^{2} is also a factor.

A **Perfect Power** is a positive integer N such that it can be expressed as a^{b}, where a and b are natural numbers > 1.

72, 108, 200, 288 are some of the first few Achilles Numbers.

The prime factors of 72 = 2 × 2 × 2 × 3 × 3.

Both 2 and 2^{2} = 4 are factors of 72.

Both 3 and 3^{2} = 9 are factors of 72.

Also, 72 can’t be represented as a^{b}.

Therefore, 72 is an Achilles Number.

Write a program in **Java** to input an integer from the user and check whether it is an Achilles Number or not.

```
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.");
}
}
```

## 4 replies on “Achilles Number Program in Java”

Sir, a program is given which states that:

The Euler’s number e, is used as the base of natural logarithm. It can be approximated using the formula.

e=1+1/1!+1/2!+1/3!+…1/n!

WAP in JAVA that approximates e using a loop that terminates when the difference between two successive values of e

differ by less than 0.0000001.

Sir,a program is given which states that:

WAP in Java to print the given series upto nth term.

1/+2 2/-3 6/+5 24/-7 120/+11…. nth term (n>0)

Sir,a program is given which states that :

WAP in JAVA to accept N numbers in a Single Dimensional Array.Now delete all the automorphic numbers from the array and display the new array after deletion.

(An automorphic number is one whose square ends with the original number itself.

Example:

INPUT: 25

OUTPUT: 25 is automorphic.)

The user should call a user-defined recursive function to check whether the number is automorphic or not.

Eg:

N=10

Sample Input:

1 2 3 4 5 6 7 8 9 10

Sample Output:

2 3 4 7 8 9 10

Sir, a program is given which states that:

The Euler’s number e, is used as the base of natural logarithm. It can be approximated using the formula.

e=1+1/1!+1/2!+1/3!+…1/n!

WAP in JAVA that approximates e using a loop that terminates when the difference between two successive values of e

differ by less than 0.0000001.