Skip to content

Commit f7593ac

Browse files
Merge pull request seeditsolution#101 from ishikagoel5628/patch-1
Create ugly numbers
2 parents 74afcfa + 3d2d15c commit f7593ac

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

ugly numbers

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# include <stdio.h>
2+
# include <string.h>
3+
4+
int main()
5+
{
6+
int n,x=0;
7+
printf("Input an integer number: ");
8+
scanf("%d",&n);
9+
10+
if (n <= 0) {
11+
printf("Input a correct number.");
12+
}
13+
while (n != 1)
14+
{
15+
if (n % 5 == 0)
16+
{
17+
n /= 5;
18+
}
19+
else if (n % 3 == 0)
20+
{
21+
n /= 3;
22+
}
23+
else if (n % 2 == 0)
24+
{
25+
n /= 2;
26+
}
27+
else
28+
{
29+
printf("It is not an ugly number.\n");
30+
x = 1;
31+
break;
32+
}
33+
}
34+
if (x==0)
35+
{
36+
printf("It is an ugly number.\n");
37+
}
38+
}

0 commit comments

Comments
 (0)