How to resolve the algorithm Sum multiples of 3 and 5 step by step in the FBSL programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sum multiples of 3 and 5 step by step in the FBSL programming language
Table of Contents
Problem Statement
The objective is to write a function that finds the sum of all positive multiples of 3 or 5 below n. Show output for n = 1000. This is is the same as Project Euler problem 1. Extra credit: do this efficiently for n = 1e20 or higher.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Sum multiples of 3 and 5 step by step in the FBSL programming language
Source code in the fbsl programming language
#APPTYPE CONSOLE
FUNCTION sumOfThreeFiveMultiples(n AS INTEGER)
DIM sum AS INTEGER
FOR DIM i = 1 TO n - 1
IF (NOT (i MOD 3)) OR (NOT (i MOD 5)) THEN
INCR(sum, i)
END IF
NEXT
RETURN sum
END FUNCTION
PRINT sumOfThreeFiveMultiples(1000)
PAUSE
You may also check:How to resolve the algorithm One-time pad step by step in the Haskell programming language
You may also check:How to resolve the algorithm Fibonacci sequence step by step in the Fexl programming language
You may also check:How to resolve the algorithm Find limit of recursion step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Minimum multiple of m where digital sum equals m step by step in the Julia programming language
You may also check:How to resolve the algorithm Towers of Hanoi step by step in the REXX programming language