int GetUglyNumber( int index ) { if( index <= 0 ) return 0; int number = 0; int UglyFound = 0; while( UglyFound < index ) { ++number; if( IsUgly( number )) ++UglyFound; } return number; }
int FindNthUglyNum(int n) { int k = 0; int i = 0; if (n <= 0) { return 0; } while (k != n) { ++i; if (IsUgly(i)) k++; } return i; }
int GetUglyNumber_Solution1(int index) { if(index <= 0) return 0; int number = 0; int uglyFound = 0; while(uglyFound < index) { ++number; if(IsUgly(number)) { ++uglyFound; } } return number; }