An Automorphic number is a number whose square ends with the same digits as the original number. E.g – 25, 76, 376 etc.

Automorphic numbers

Steps to Check Automorphic Number in Java

  1. Take a number as input (num).
  2. Square the number (sqr).
  3. Count the number of digits of (num) using while loop (c).
  4. Compare the last (c) digits of (sqr) with the (num).
  5. If they are equal then the number is Automorphic else not.

Check Whether a number is an Automorphic Number in Java

Output

Java Program to Find all Automorphic Numbers in the Interval

We know how to check whether a number is Automorphic or not using the above java program. Now, to find all Automorphic numbers in the given range, we need to define a function which returns true or false depending on whether the passed number as a parameter is automorphic or not. We will check for all the values in the given interval by passing it to the function one by one using loop.

Output

Any Doubts comment below.

Leave a Reply

Close Menu