Lisa 的圍巾 ( 50分 )
Ponchimeow opened this issue · comments
Ponchimeow commented
目前50分,待檢修
function pa(s) {
const arr = s.split(' ');
const a = parseInt(arr[0]);
const b = parseInt(arr[1]);
let res = 0;
if (a >= 1 && b <= 7000) {
for (let i = a; i <= b; i += 1) {
if (!isPrime(i)) {
res += i;
}
}
return res;
}
}
function isPrime(n) {
if (n === 1) return false;
if (n === 2) return true;
for (let i = 2; i < n; i += 1) {
if (n % i === 0) return false;
else return true;
}
}