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

Source code in the bqn programming language

Sum  +´·(0=3|5|)/


Sum  {
  m  (0=3|5|)15  hl  15(÷˜|)𝕩
  (+´lm×15(×+)h) + (15×(+´m)×2÷˜h×h-1) + h×+´m×15
}


  

You may also check:How to resolve the algorithm Enumerations step by step in the Lua programming language
You may also check:How to resolve the algorithm Call a foreign-language function step by step in the CMake programming language
You may also check:How to resolve the algorithm Morse code step by step in the Racket programming language
You may also check:How to resolve the algorithm Penney's game step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Accumulator factory step by step in the Oforth programming language