Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Multiples of 3 or 5

*JS

const solution = (number) => {
  return (number < 1 ? 0 : [...Array(number).keys()].filter(num => num % 3 == 0 || num % 5 == 0).reduce((a,b) => a+b));
}

*ruby

def solution(number)
  (1...number).select { |num| num % 3 == 0 || num % 5 == 0 }.sum
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.