Computer Science, asked by garvchhabra4803, 1 year ago

To write a program and check whether it is a automorphic number or not

Answers

Answered by sofia147
2
In mathematics, an automorphic number is a number whose square "ends"in the same digits as the number itself. For example 5×5=25,6×6=36 and 76×76=5776 so, 5,6 and 7 are all automorphic numbers. I hope this is OK for you plz mark me as brainlist
Answered by BrainlyPromoter
6

Sample program to check whether the number entered by user is automorphic:

import java.util.*;

public class BrainlyPromoter

{

   public static void chapter()

   {

       Scanner tp=new Scanner(System.in);

       System.out.println("Enter a number that you want to check if its automorphic or not.");

       int n=tp.nextInt();

       int square=0, b=0, ct=1;

       square=n*n;

       int d=n;

       int l=n;

       while(n!=0)

       {

           b++;

           n=n/10;

       }

       for(int k=1;k<=b;k++)

       {

           ct=ct*10;

       }

       int dig=square%ct;

       if(dig==d)

       {

           System.out.println("Entered number is an automorphic number!");

       }

       else    System.out.println("Entered number is not an automorphic number!");

   }

}

Output:

Enter a number that you want to check if its automorphic.

25

Entered number is an automorphic number.

Similar questions