Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

is power javascript

function solution(n) {
    if (n === 1) {
        return true;
    }
    for (let i = 2; i < n; i++) {
        let power = i;
        while (power < n) {
            power *= i;
        }
        if (power === n) {
            return true;
        }
    }
    return false;
}
 
PREVIOUS NEXT
Tagged: #power #javascript
ADD COMMENT
Topic
Name
8+3 =