sum of all multiples of 3 and 5 below 100
c = list(range(1,100))
total = 0
for i in (c):
if i % 3 == 0 or i % 5 == 0:
total += i
print (total)
sum of all multiples of 3 and 5 below 100
c = list(range(1,100))
total = 0
for i in (c):
if i % 3 == 0 or i % 5 == 0:
total += i
print (total)
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))
Sum of all the multiples of 3 or 5
const findSum = n => {
let countArr = []
for(let i = 0; i <= n; i++) countArr.push(i)
let finalArr = countArr.map(digit => {
if(digit % 3 === 0 || digit % 5 === 0) return digit
else return 0
}).reduce((acc , curr) => acc + curr)
return finalArr
}
console.log(findSum(10))
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us