Showing posts with label automorphic-number. Show all posts
Showing posts with label automorphic-number. Show all posts

Friday, July 31, 2020

Write a program to input a number and check whether it is Automorphic Number or not?(25^2=625, 5^2=25)

65)  Write a program to input a number and check whether it is Automorphic Number or not?(252=625, 52=25)


import java.util.*;
public class Automorphic
{
     public static void main(String args[ ])
   {
              Scanner sc = new Scanner (System.in);
              System.out.println("Enter a number");
              int a = sc.nextInt();
              int k = a;
              int c = 0;
              while(k>0)
              {
                  k=k/10;
                  c++;
              }
              int p = a*a;
              int x = (int)Math.pow(10,c);
              int m = p%x;
              if(m==a)
              {
                  System.out.println("Entered number is a AUTOMORPHIC Number");
              }
              else
              {
                  System.out.println("Entered number is not a AUTOMORPHIC Number");
              }
   }
}

Output : 




 jhvghvgk ;nkjn ,nkjhj