Benjamin
18-12-2023, 12:35
The first problem for the Euler Project is as follows:
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5. 6. and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.
So I wrote the code below, which gives 36,560. The Euler Project says this answer is incorrect. Can someone give me a hint about what's wrong? I honestly can't see it.
USES "Console"
DIM i AS Integer
DIM Total AS Word VALUE 0
FOR i = 1 TO 999
IF MOD(i, 3) = 0 THEN
Total += i
ELSEIF MOD(i, 5) = 0 THEN
Total += i
END IF
NEXT
CONSOLE_WRITELINE Total
WAITKEY
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5. 6. and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.
So I wrote the code below, which gives 36,560. The Euler Project says this answer is incorrect. Can someone give me a hint about what's wrong? I honestly can't see it.
USES "Console"
DIM i AS Integer
DIM Total AS Word VALUE 0
FOR i = 1 TO 999
IF MOD(i, 3) = 0 THEN
Total += i
ELSEIF MOD(i, 5) = 0 THEN
Total += i
END IF
NEXT
CONSOLE_WRITELINE Total
WAITKEY