0

Hello friends..**Ugly number is a number whose prime factors are only 1,2,3 or 5.**

I had written a program for finding n`th ugly number in the series.Now the series is 1,2,3,4,5,6,8,9,10,12,15...these are first 11 ugly no`s.

Now In my program if we put m=11 then output will be 15.

It will work only up to m=239,Onwords it doesn`t work.**plz help me for finding 1500`th ugly number.**

```
[B]/*PROGRAM TO FIND AND PRINT 1500`th UGLY NUMBER*/[/B]
//UGLY NUMBER IS A NUMBER WHOSE PRIME FACTORS ARE 2,3 OR 5
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<ctype.h>
void main()
{
long int i;
int j,k,l,p,n,m=240,c,f=0,x[20];
int flag=1;
clrscr();
for(i=1;i<=500000;i++)
{
n=i;
k=0;
for(j=1;j<=i;j++)
{
if(n%j==0)
{
k++;
x[k]=j;
n=n/j;
j=1;
}
if(x[k]!=1 && x[k]!=2 && x[k]!=3 && x[k]!=5)
{
flag=0;
break;
}
}
if(flag==1)
{
c=0;
for(p=1;p<=k;p++)
{
if(x[p]==1 || x[p]==2 || x[p]==3 || x[p]==5)
c++;
}
if(c==k)
{
f++;
if(f==m)
{
clrscr();
printf("\n\nThe 1500`th ugly number is <%ld>.",i);
getch();
exit(0);
}
}
}
flag=1;
}
printf("error");
getch();
}
```