function GetUglyNumber_Solution(index) { // write code here if(index==0) return 0 let ugly = [1] let two = 0, three = 0, five =0 for(let i=1;i<index;i++){ ugly[i]= Math.min(2*ugly[two],3*ugly[three],5*ugly[five]) if(ugly[i] == 2*ugly[two]) two++ if(ugly[i] == 3*ugly[three]) three++ if(ugly[i] == 5*ugly[five]) five++ } return ugly[index-1] }