public class Solution { public int GetUglyNumber_Solution(int index) { if(index<=0){ return 0; } int[] p = new int[index]; p[0]=1; int p2=0; int p3=0; int p5=0; int num=1;//索引 while (num < index){ int min = Min(p[p2]*2,p[p3]*3,p[p5]*5); p[num] = min; while(p[p2]*2<=p[num]){ p2++; } while(p[p3]*3<=p[num]){ p3++; } while(p[p5]*5<=p[num]){ p5++; } num++; } int res = p[num-1]; return res; } private static int Min(int i, int j, int k) { int min = i< k ? min : k; return min; }}