http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=2843
這題用迴圈依序除以2,3,5,若都不能整除則跳出迴圈當x=1時i就是uglu number了!
#include<stdio.h>
int main(){
int n,i=1,count=0,x=1;
scanf("%d",&n);
while(1){
x=i;
while(x!=1){
if(x%2==0)
x/=2;
else if(x%3==0)
x/=3;
else if(x%5==0)
x/=5;
else
break;
}
if(x==1)
count++;
if(count==n)
break;
i++;
}
printf("%d\n",i);
/*
題目:[C_MM110-中] Ugly number
作者:1010
時間:西元 2016 年 7 月 */
}