Last active
June 29, 2024 18:48
-
-
Save ItsWachira/08cbadb2d702184db55469d3cc4d9f1b to your computer and use it in GitHub Desktop.
What is Project Euler? Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems. The motivatio…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Multiples of 3 or 5 | |
| Problem 1 | |
| If we list all the natural numbers below 10 that are multiples of 3 or 5 , we get 3,5,6,9. The sum of these multiples is 23 | |
| . | |
| Find the sum of all the multiples of 3 or 5 below 1000. | |
| solution (js) ---- | |
| let totalNum = 1000 | |
| let sum= 0 | |
| function findSum (){ | |
| for (let i=0; i < totalNum; i++){ | |
| if ( i % 3 === 0 || i % 5 === 0){ | |
| sum+=i; | |
| } | |
| } | |
| return sum | |
| } | |
| const totalSum = findSum() | |
| console.log(totalSum); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment