Javatpoint Logo
Javatpoint Logo

Achilles Number in Java

In this section, we will learn what is an Achilles number and also create Java programs to check if the given number is an Achilles number or not. The Achilles number program frequently asked in Java coding tests and academics.

Achilles Number

A number that is a powerful number but not a perfect power is known as Achilles number. It is an integer sequence A052486 in OEIS.

  • Powerful Numbers: It is a positive integer such that for every prime factor p of N, p2 is also divided it. For example, the number 36 is a powerful number because it is divisible by both 3 and square of 3, i.e. 9. Some other powerful numbers are 1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, etc.
  • Perfect Power: It is also a positive integer such that it can be expressed as ab. Where a and b are integers, and b is greater than 1 and a is greater than 0. For example, 64 can be expressed as 82.

Let's understand it mathematically through an example.

Achilles Number Example

Let's check the number 108 is an Achilles number or not.

The factors of 108 = 2 x 2 x 3 x 3 x 3.

Prime factors are 2 and 3.

Square of prime factors are:
Both 2 and 22 = 4 divides 108.
Both 3 and 32 = 9 divides 108.
But, the number 108 cannot be represented as ab.
Hence, 108 is an Achilles number.

Let's take another number 784 and check it is an Achilles number or not.

The factors of 784 = 2 x 2 x 2 x 2 x 7 x 7.

Prime factors are 2 and 7.

Square of prime factors are:
Both 2 and 22 = 4 divides 784.
Both 7 and 72 = 49 divides 784.
But, the number 784 can be represented as 282.
Hence, 784 is not an Achilles number.

Similarly, we can check other numbers. First few Achilles numbers are 72, 108, 200, 288, 392, 432, 500, 648, 675, 800, 864, 968, 972, 1125, 1152, 1323, 1352, 1372, 1568, 1800, 1944, 2000, 2312, 2592, 2700, 2888, 3087, 3200, 3267, 3456, 3528, 3872, 3888, 4000, 4232, 4500, 4563, 4608, 5000, etc.

Steps to Find Achilles Number

  1. Read or initialize a number N.
  2. Check if the given number N is powerful or not.
  3. Check if the given number N is perfect power or square or not.
  4. If N is powerful but not perfect, the number N is an Achilles number, else not.

Let's implement the above steps in a Java program.

Achilles Number Java Program

AchillesNumberExample.java

Output 1:

Achilles Number in Java

Output 2:

Achilles Number in Java




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA