UGLY NUMBER OR NOT
Consider the following I/O samples.
SAMPLE INPUT: 12
SAMPLE OUTPUT: UGLY NUMBER
UGLY NUMBERS are those whose prime factors are 2, 3 and 5.
C PROGRAM:
#include <stdio.h>
int main()
{
int num,fact=1;
scanf("%d",&num);
while(num!=1)
{
fact++;
while(num%fact==0)
num=num/fact;
}
if(fact<=5)
printf("UGLY NUMBER");
else
printf("NOT AN UGLY NUMBER");
return 0;
}
#include <stdio.h>
int main()
{
int num,fact=1;
scanf("%d",&num);
while(num!=1)
{
fact++;
while(num%fact==0)
num=num/fact;
}
if(fact<=5)
printf("UGLY NUMBER");
else
printf("NOT AN UGLY NUMBER");
return 0;
}
OUTPUT:

The given source code in C program "FOR UGLY NUMBER OR NOT" is short and simple to understand. The source code is well tested in DEV-C++ and is completely error free.

The given source code in C program "FOR UGLY NUMBER OR NOT" is short and simple to understand. The source code is well tested in DEV-C++ and is completely error free.
If you have any feedback about this article and want to improve this, please comment in the comment section.
Comments
Post a Comment