← Back to challenges

Testing K^K == N?

JavaScriptHardnumbersmathvalidationbit_operations

Instructions

Write a function that returns true if k^k == n for input (n, k) and return false otherwise.

Examples

kToK(4, 2) ➞ true

kToK(387420489, 9) ➞ true
// 9^9 == 387420489

kToK(3124, 5) ➞ false

kToK(17, 3) ➞ false

Notes

The ^ operator refers to exponentiation operation, not the bitwise XOR operation.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: ES6: Destructuring Objects III