← Back to challenges

Perfect Roots

PythonHardalgebramathnumbers

Instructions

Given a number n, find if its 2nd, 4th and 8th roots are all integers (perfect roots), return True if it exists, False if not.

Examples

perfect_roots(256) ➞ True
# 2nd root of 256 is 16
# 4th root of 256 is 4
# 8th root of 256 is 2

perfect_roots(1000) ➞ False

perfect_roots(6561) ➞ True

Notes

n > 1

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Innokodakademija's Markdown Formatting