-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautomorphic.c
More file actions
48 lines (46 loc) · 873 Bytes
/
automorphic.c
File metadata and controls
48 lines (46 loc) · 873 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>
int main()
{
int n;
printf("Enter a number: ");
if (scanf("%d", &n) != 1)
{
printf("Invalid input. Please enter a valid integer.\n");
return 1;
}
if (n <= 0)
{
printf("Invalid input. Please enter a positive number.\n");
return 1;
}
int divisor=1;
int original = n;
int sq = n * n;
int temp = n;
int length = 0;
if (n == 0)
{
length = 1;
}
else
{
while (temp > 0)
{
temp /= 10;
length++;
}
}
for (int j = 0; j < length; j++)
{
divisor *= 10;
}
if (sq % divisor == original)
{
printf("It is a automorphic number");
}
else
{
printf("It is not a automorphic number");
}
return 0;
}