Project Euler - Problem 1: Multiples of 3 and 5

Tell us what’s happening:
Apparently I only fail at one test (number = 1000) with my code. Does anybody see why? The result is also off by 1000…
Your code so far

function multiplesOf3and5(number) {
  let i = 1;
  let sum = 0;
  while(i<=number){
    if(i%3 == 0 || i%5 == 0){
      sum = sum + i
    }
    i++
  }

  return sum;
}

console.log(multiplesOf3and5(1000));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.63

Challenge: Project Euler - Problem 1: Multiples of 3 and 5

Link to the challenge:

“Find the sum of all the multiples of 3 or 5 below the provided parameter value number.”

I have bolded the word in the instructions you should pay attention to.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.