A delightful Automorphic number
For other java programs clickhttps://wordpress-343193-1101484.cloudwaysapps.com/patterns-part-4strings
A number is called an Automorphic number if its square ends in the same digits as the number itself.
For example, N=6 is an automorphic number because 6*6=36
N=25 is an automorphic number because 25*25=625
For other java programs click
Pattern programs in java part 1: Simple loop programs
Write a program to accept a number and print whether it is an automorphic number or not.
import java.io.*;
class automorphic//one whose square ends in the same digits as the number itself e.g., 25
{
public static void main() throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number");
int num=Integer.parseInt(br.readLine());
int pro=(int)Math.pow(num,2);
if(pro%10==num||pro%100==num)
{
System.out.println("AN Automorphic Number");
}
else
{
System.out.println("Not An Automorphic Number");
}
}
}Output:
Enter a number
6
AN Automorphic Number
for more videos related to java click https://www.youtube.com/user/trushnatej
Related Posts
Continue learning with these related articles
Sum of First n Natural Numbers in Java (Loop and Formula)
Find the sum of the first n natural numbers in Java with a for loop, a while loop and the formula n(n + 1)/2, with a dry run and the sums of even numbers, odd numbers, squares and cubes.
Prime Number Program in Java: Check a Number and Print Primes in a Range
Check whether a number is prime in Java by counting its factors, a faster square-root method with isPrime(), and a program that prints all prime numbers in a range.

Encapsulation, Access Specifiers and Scope of Variables in Java for ICSE Class 10
ICSE Class 10 Computer Applications notes on encapsulation: private, default, protected and public access, data hiding with getter and setter methods, instance vs static (class) variables, local variables and scope, with a solved BankAccount program.