How to resolve the algorithm Sum multiples of 3 and 5 step by step in the EasyLang 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 EasyLang 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 EasyLang programming language

Source code in the easylang programming language

func msum35 n .
   for i = 1 to n
      if i mod 3 = 0 or i mod 5 = 0
         sum += i
      .
   .
   return sum
.
print msum35 999

  

You may also check:How to resolve the algorithm Roots of a quadratic function step by step in the Maple programming language
You may also check:How to resolve the algorithm Loops/Continue step by step in the C# programming language
You may also check:How to resolve the algorithm Variable size/Get step by step in the ALGOL 68 programming language
You may also check:How to resolve the algorithm Sort an array of composite structures step by step in the M2000 Interpreter programming language
You may also check:How to resolve the algorithm Tokenize a string step by step in the Swift programming language