📌  相关文章
📜  day 25 运行时间和复杂性hackerrank解决方案javascript代码示例

📅  最后修改于: 2022-03-11 15:04:21.435000             🧑  作者: Mango

代码示例1
// day 25 running time and complexity hackerrank solution javascript
function processData(input) {
    //Enter your code here
    input.split('\n').slice(1).map((n, i) => {
        console.log(isPrime(n) ? 'Prime' : 'Not prime');
    });

    function isPrime(n) {
        if (n == 1) return false;

        for (let i = 2; i * i <= n; i++) {
            if (n % i == 0) return false;
        }

        return true;
    }
}