Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

find the sum of all the multiples of 3 or 5 below 1000 python

nums = [3, 5]

result = 0
for i in range(0,1000):
    if i%3 == 0 or i%5 == 0:
        result += i

print(result)
Comment

sum of multiples of 3 or 5 python

total = []

for num in range(0,1001):
    if (num % 3 == 0) or (num % 5 == 0):
        total.append(num)
        
print(sum(total))
Comment

Sum of all the multiples of 3 or 5

const findSum = n => {
  let countArr = []
  
  for(let i = 0; i <= n; i++) if(i % 3 === 0 || i % 5 === 0) countArr.push(i) 
  return countArr.reduce((acc , curr) => acc + curr)
}
console.log(findSum(5))

// With love @kouqhar
Comment

PREVIOUS NEXT
Code Example
Python :: merge two netcdf files using xarray 
Python :: how to create pyw file 
Python :: fast output python 
Python :: how to use modulo in python 
Python :: new line print python 
Python :: how to convert list to all uppercase 
Python :: Creating Python Sets 
Python :: character to ascii python 
Python :: how to remove element from nested list in python 
Python :: balancing paranthesis python 
Python :: print out session information django 
Python :: one line if statement python without else 
Python :: Add Cog to bot in Discord.py 
Python :: flask get uploaded file size 
Python :: comment out multiple lines in python 
Python :: input for competitive programming 
Python :: take absolute value in python 
Python :: how to print out even index in python 
Python :: python remove by index 
Python :: python milisegundos 
Python :: python region 
Python :: how to make a comment in python 
Python :: how to make a python program on odd and even 
Python :: django redirect 
Python :: __lt__ 
Python :: proper function pandas 
Python :: how to find and remove certain characters from text string in python 
Python :: flask on gevent over https 
Python :: Aggregate on the entire DataFrame without group 
Python :: python for unity 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =