forked from NIKHILSINGH1510/Test_Repo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpr4
More file actions
107 lines (54 loc) · 663 Bytes
/
pr4
File metadata and controls
107 lines (54 loc) · 663 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
Program Name:- All happy numbers between 1 to n.
INPUT:-
#include<stdio.h>
int main()
{
int num,temp,sum;
int i;
int limit;
printf("Enter a number(upper limit):");
scanf("%d",&limit);
for(i=1;i<=limit;i++)
{
num=i;
sum=0;
while(sum!=1&&sum!=4)
{
sum=0;
while(num>0)
{
temp=num%10;
sum+=(temp*temp);
num=num/10;
}
num=sum;
}
if(sum==1)
printf("%d\n",i);
}
return 0;
}
OUTPUT:-
Enter a number(upper limit):100
1
7
10
13
19
23
28
31
32
44
49
68
70
79
82
86
91
94
97
100
Get it on Google Play:-
https://play.google.com/store/apps/details?id=com.herokuapp.codecracker