Ugly Powers
0:00:00
A Hamming Number (also called an ugly number) is any positive integer that has its set of prime factors as a subset of the prime numbers 2, 3, and 5. On the other hand, a prime power is produced using any integer raised to a prime , and is represented as .
As such, we can create a theoretical term, an “ugly power,” which is any ugly number multiplied by any arbitrary positive integer . We can represent this by having any ugly number , and an ugly power be .
Write a function ugly_powers(s: set) -> bool
which takes a set and returns a boolean value determining whether or not all the elements of set are all ugly powers.
Note: Can you write a solution that’s approximately ?
Example:
ugly_powers({1, 2, 5, 10}) -> True
Personalized based on your user activity, skill level, and preferences.
.
.
.
.
Comments