+ 5

[ASSIGNMENT] :: Find the ugly number

Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 
 shows the first 11 ugly numbers. By convention, 1 is included. Given a number n, the task is to find n’th Ugly number. Input : n = 7 Output : 8 Input : n = 10 Output : 12 Input : n = 15 Output : 24 Input : n = 150 Output : 5832 Show me your coding skills, SoloLearners..

2nd Aug 2017, 8:29 AM
Kartikey Sahu
Kartikey Sahu - avatar
8 Answers
2nd Aug 2017, 9:56 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 5
Works up to 600 on SoloLearn... Can't get it faster :/ https://code.sololearn.com/cBUkGl0Pk3DG/?ref=app
10th Aug 2017, 6:17 PM
Julian Fechner
Julian Fechner - avatar
2nd Aug 2017, 9:12 AM
Garikai
Garikai - avatar
+ 3
My submission (little late but I had fun doing it) https://code.sololearn.com/c4lkt1hHLZfk/?ref=app
2nd Aug 2017, 7:40 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
3rd Aug 2017, 8:57 AM
yuri
+ 1
Works with larger input without freezing your browser ^^ https://code.sololearn.com/cL7DDwAsWJo9/?ref=app It uses O(n) space though.
2nd Aug 2017, 10:37 AM
Dennis
Dennis - avatar
+ 1
Here! Really slow, only works on here till about the 10th ugly number without time limit exceeded, but it is accurate, tested it on my computer to position 150 and got correct result. Also checks for valid input. https://code.sololearn.com/cd6Qfnl673KC/?ref=app
2nd Aug 2017, 1:08 PM
Vari93
Vari93 - avatar
+ 1
Sorry to invade, but just to make sure your challenge questions are visible to everyone and are easier to find: https://www.sololearn.com/Discuss/583904/?ref=app
3rd Aug 2017, 5:26 AM
Garikai
Garikai - avatar