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 :: pandas read cell value by index and column name 
Python :: sqlite3 delete row python 
Python :: how to make a pause in python 
Python :: django admin customization 
Python :: matplotlib logarithmic scale 
Python :: how to return total elements in database django 
Python :: df reset index 
Python :: python turtle write 
Python :: How to Get the Difference Between Sets in Python 
Python :: negative index in python list 
Python :: difference between object and class in python 
Python :: adf test python 
Python :: are tuples mutable 
Python :: python reverse words in string 
Python :: how to remove rows with certain values pandas 
Python :: read_table python 
Python :: how to use a string variable as a variable name in python 
Python :: how to reset index after dropping rows pandas 
Python :: python adding digits 
Python :: set http response content type django 
Python :: matplotlib cheatsheet 
Python :: how to get input python 
Python :: python print color 
Python :: python remove string from string 
Python :: pip install for python 2 and python3 
Python :: how can i make a list of leftovers that are str to make them int in python 
Python :: unpack too many values in python 
Python :: sqlite query in python 
Python :: python merge lists 
Python :: python create sqlite db in memory 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =