function sumPrimes(num) {
// Helper function to check primality
function isPrime(num) {
for (let i = 2; i <= Math.sqrt(num); i++) {
if (num % i == 0)
return false;
}
return true;
}
// Check all numbers for primality
let sum = 0;
for (let i = 2; i <= num...
THANK YOU SO MUCH!!!!
I thought that i is increased with every iteration and that’s why I thought i = 3, because when x = 4, was the second iteration and that it would be i = 3.
but now I still don't understand, if x = 5, the i is still 2? beacouse if i is still 2, the condition of (i === x -...
Thank you for your answear.
but I don't understand the part where:
x++; x=4;
i=3;
I don't know how my the code does not add 4 beause the condition of ``else if `` is applied:
(i===x-1); (3 === 4 -1 )
added(which is 5 ) += 4 (is reciving 4 becouse is executing this line of code else if...
hello,
Can someone help me please with this algorithm?
my example is 10.
(A prime number is a whole number greater than 1 with exactly two divisors: 1 and itself. For example, 2 is a prime number because it is only divisible by 1 and 2. In contrast, 4 is not prime since it is divisible by 1, 2...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.