+ 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..
8 Answers
+ 10
+ 5
Works up to 600 on SoloLearn...
Can't get it faster :/
https://code.sololearn.com/cBUkGl0Pk3DG/?ref=app
+ 3
My submission (little late but I had fun doing it)
https://code.sololearn.com/c4lkt1hHLZfk/?ref=app
+ 1
Works with larger input without freezing your browser ^^
https://code.sololearn.com/cL7DDwAsWJo9/?ref=app
It uses O(n) space though.
+ 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
+ 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