Checking Perfect Power

Checking Perfect Power

A positive integer n is a perfect power if it can be expressed as the power be for some two integers b and e that are both greater than one. (Any positive integer n can always be expressed as the trivial power n1, so we don’t care about those.) For example, the integers 32, 125 and 441 are perfect powers since they equal 25, 53 and 212, respectively.

This function should determine whether the positive integer n is a perfect power. Your function needs to somehow iterate through a sufficient number of possible combinations of b and e that could work, returning true right away when you find some b and e that satisfy be == n, and returning false when all relevant possibilities for b and e have been tried and found wanting.

Since n can get pretty large, your function should not examine too many combinations above and beyond those that are both necessary and sufficient to reliably determine the answer. Achieving this efficiency is the central educational point of this problem.

Input: Integer (number).

Output: Logic value (boolean).

Examples:

assert.strictEqual(perfectPower(8), true);
assert.strictEqual(perfectPower(42), false);
assert.strictEqual(perfectPower(441),...
You should be an authorized user in order to see the full description and start solving this mission.