-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutomorphic.java
More file actions
31 lines (25 loc) · 951 Bytes
/
Automorphic.java
File metadata and controls
31 lines (25 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package SelfEvol;
//Q 2 wap to check whether a single digit number is automorphic number or not .
//automorphic number is number whose square ends with number itself i.e 5 * 5 =25
//if automorphic display "its automorphic number else not automorphic .
import java.util.Scanner;
public class Automorphic {
public static void main(String[] args)
{
int num;
Scanner sc = new Scanner(System.in);
System.out.println("ENTER NO TO CHECK IS IT AUTOMORPHIC");
num=sc.nextInt();
int square= num*num;
int lastdigit= (square%10); //to find last digit of square
System.out.println( square);
System.out.println(lastdigit);
if( num>0)
{
if (num%10==square%10) //to compare no last digit and sqare last digit.
System.out.println(" automorphic");
else
System.out.println(" NOT automorphic");
}
}
}