You are viewing a single comment's thread. Return to all comments →
JavaScript
const data = input.split(/[\n]/g); data.shift(); data.forEach(e => { e = parseInt(e); let isPrime = true; if(e == 1) return console.log("Not prime"); for(i = 2; i < e; i++) { if(e % i == 0) { isPrime = false; break; } } if(isPrime) console.log("Prime"); else console.log("Not prime"); });
Seems like cookies are disabled on this browser, please enable them to open this website
Day 25: Running Time and Complexity
You are viewing a single comment's thread. Return to all comments →
JavaScript