Computer Science, asked by JoyeetaDas, 8 months ago

variable description table for automorphic number in Java​

Answers

Answered by Vyomsingh
9

Automorphic Number:-

An automorphic number is a number whose square "ends" in the same digits as the number itself.

______________________________

Code:-

  1. class Automorphic
  2. {
  3. public static void main (int n)
  4. {
  5. int m=n;
  6. int squ=n*n,j=1;
  7. for(;m>0;m=m/10)
  8. {
  9. j=j*10;
  10. }
  11. if((squ%j)==m
  12. System.out.println("Automorphic Number");
  13. else
  14. System.out.println(" Not a Automorphic Number");
  15. }
  16. }

_____________________________

Input:-

5

Output:-

Automorphic Number

_____________________________

Variable Discription Table:-

In The attachment Above:-

Attachments:
Answered by anindyaadhikari13
8

\star\:\:\:\bf\large\underline\blue{Question:-}

  • Write a program to check whether a number is automorphic number or not.

\star\:\:\:\bf\large\underline\blue{Source\:Code:-}

  • A number is said to be automorphic number if the square of the number ends with the same digits as the number has. Examples of automorphic number are 1,5,6,25 625 and so on.

class IfAutomorphic {

public static void main(int n) {

int s=n*n;

String s1=Integer.toString(s),s2=Integer.toString(n);

if(s1.endsWith(s2) )

System.out.println("Automorphic Number. ");

else

System.out.println("Not an Automorphic Number.");

}

}

For variable description,see the attachment.

Attachments:
Similar questions