maths.special_numbers.ugly_numbers¶
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 an integer n, we have to find the nth ugly number.
For more details, refer this article https://www.geeksforgeeks.org/ugly-numbers/
Functions¶
|
Returns the nth ugly number. |
Module Contents¶
- maths.special_numbers.ugly_numbers.ugly_numbers(n: int) int ¶
Returns the nth ugly number. >>> ugly_numbers(100) 1536 >>> ugly_numbers(0) 1 >>> ugly_numbers(20) 36 >>> ugly_numbers(-5) 1 >>> ugly_numbers(-5.5) Traceback (most recent call last):
…
TypeError: ‘float’ object cannot be interpreted as an integer