6 kyu

Multiples of 3 and 5 redux

937 of 2,011yumaikas

Description:

The galactic games have begun!

It's the galactic games! Beings of all worlds come together to compete in several interesting sports, like nroogring, fredling and buzzing (the beefolks love the last one). However, there's also the traditional marathon run.

Unfortunately, there have been cheaters in the last years, and the committee decided to place sensors on the track. Committees being committees, they've come up with the following rule:

A sensor should be placed every 3 and 5 meters from the start, e.g. at 3m, 5m, 6m, 9m, 10m, 12m, 15m, 18m….

Since you're responsible for the track, you need to buy those sensors. Even worse, you don't know how long the track will be! And since there might be more than a single track, and you can't be bothered to do all of this by hand, you decide to write a program instead.

Task

Return the sum of the multiples of 3 and 5 below a number. Being the galactic games, the tracks can get rather large, so your solution should work for really large numbers (greater than 1,000,000).

Examples

10 should return 23 because 23 = 3 + 5 + 6 + 9
20 should return 78 because 78 = 3 + 5 + 6 + 9 + 10 + 12 + 15 + 18
Algorithms
Mathematics

Stats:

CreatedJan 18, 2015
PublishedJan 18, 2015
Warriors Trained5410
Total Skips324
Total Code Submissions12780
Total Times Completed2011
Python Completions937
JavaScript Completions776
Haskell Completions161
Ruby Completions130
COBOL Completions11
C Completions113
NASM Completions11
Total Stars129
% of votes with a positive feedback rating92% of 324
Total "Very Satisfied" Votes277
Total "Somewhat Satisfied" Votes39
Total "Not Satisfied" Votes8
Ad
Contributors
  • yumaikas Avatar
  • jhoffner Avatar
  • ZozoFouchtra Avatar
  • bkaes Avatar
  • GiacomoSorbi Avatar
  • Firefly2002 Avatar
  • Voile Avatar
  • rowcased Avatar
  • akar-0 Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
  • PetitLu117 Avatar
Ad