Project Euler Problems for Learn Programming - Solution 1 (Python & Javascript)
Hey SteemIt community. Did you heard about Project Euler? If you don't know please review this website: Project Euler
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 motivation for starting Project Euler, and its continuation, is to provide a platform for the inquiring mind to delve into unfamiliar areas and learn new concepts in a fun and recreational context.
Problem 1
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.
Steps
- Declare empty array
- Select natural numbers below 1000 in for loop
- If number divisible without remainder with 3 or 5 add to array
- Print sum of values in array
Solution (Python)
def find_sum(number)
numbers = []
for i in range(1,number):
if i%3 == 0 or i%5 == 0:
numbers.append(i)
print(sum(numbers))
find_sum(1000)
Solution (Javascript)
function findSum(number) {
numbers = [];
for (i = 1; i < number; i++) {
if (i % 3 == 0 || i % 5 == 0) {
numbers.push(i);
}
}
console.log(numbers.reduce((a, b) => a + b, 0))
}
findSum(1000)
Result: 233168
Leave Project Euler Problems for Learn Programming - Solution 1 (Python & Javascript) to:
Read more #javascript posts
Best Posts From scaevola
We have not curated any of scaevola's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From scaevola
- Ink Protocol - Merkeziyetsi Ödeme ve İtibar Platformu
- Acorn Collective - Adil Kitle Fonlama Platformu
- Tune - Müzik Endüstrisi İçin Demokratik Bir Ekosistem
- CoinJanitor ile Ölü Coinler Kripto Ekonomiye Katkı Sağlayacak
- Whalesburg Madencilik Platformu
- Oyun Tasarımı Notları - Bölüm 4
- Oyun Tasarımı Notları - Bölüm 3
- Oyun Tasarımı Notları - Bölüm 2
- Oyun Tasarımı Notları - Bölüm 1
- Zorlananlar ve Nasıl Başlayacağını Bilemeyenler İçin Günlük Tutma Metodları