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

Source code in the 11l programming language

F sum35(limit)
   V sum = 0
   L(i) 1 .< limit
      I i % 3 == 0 | i % 5 == 0
         sum += i
   R sum

print(sum35(1000))

  

You may also check:How to resolve the algorithm Singly-linked list/Element definition step by step in the Logo programming language
You may also check:How to resolve the algorithm Rare numbers step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Polymorphic copy step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Web scraping step by step in the M2000 Interpreter programming language
You may also check:How to resolve the algorithm Modular exponentiation step by step in the Ada programming language