Results 1 to 6 of 6

Thread: Two Consoles

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Dec 2023
    Posts
    24
    Rep Power
    4

    Euler Problem No. 1

    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
    
    Last edited by Benjamin; 18-12-2023 at 13:05. Reason: Changed subject

Members who have read this thread: 0

There are no members to list at the moment.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •