variable description table for automorphic number in Java
Answers
Answered by
9
Automorphic Number:-
An automorphic number is a number whose square "ends" in the same digits as the number itself.
______________________________
Code:-
- class Automorphic
- {
- public static void main (int n)
- {
- int m=n;
- int squ=n*n,j=1;
- for(;m>0;m=m/10)
- {
- j=j*10;
- }
- if((squ%j)==m
- System.out.println("Automorphic Number");
- else
- System.out.println(" Not a Automorphic Number");
- }
- }
_____________________________
Input:-
5
Output:-
Automorphic Number
_____________________________
Variable Discription Table:-
In The attachment Above:-
Attachments:
Answered by
8
- Write a program to check whether a number is automorphic number or not.
- 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