← Back to challenges

Powerful Numbers

PythonHardconditionsmathnumbersvalidation

Instructions

Given a positive number x:

p = (p1, p2, …)
# Set of *prime* factors of x

If the square of every item in p is also a factor of x, then x is said to be a powerful number.

Create a function that takes a number and returns True if it's powerful, False if it's not.

Examples

is_powerful(36) ➞ True
# p = (2, 3) (prime factors of 36)
# 2^2 = 4 (factor of 36)
# 3^2 = 9 (factor of 36)

is_powerful(27) ➞ True

is_powerful(674) ➞ False

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.