← Back to challenges

Perfect Roots

JavaScriptHardalgebramathnumbers

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

perfectRoots(256) ➞ true
// 2nd root of 256 is 16
// 4th root of 256 is 4
// 8th root of 256 is 2

perfectRoots(1000) ➞ false

perfectRoots(6561) ➞ true

Notes

n > 1

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Sum of Cubes