6 kyu

Multiples of 3 or 5

136,311 of 443,957jhoffner

Description:

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Finish the solution so that it returns the sum of all the multiples of 3 or 5 below the number passed in.

Additionally, if the number is negative, return 0.

Note: If the number is a multiple of both 3 and 5, only count it once.

Courtesy of projecteuler.net (Problem 1)

Mathematics
Algorithms

More By Author:

Check out these other kata created by jhoffner

Stats:

CreatedMar 21, 2013
PublishedMar 28, 2013
Warriors Trained770633
Total Skips62948
Total Code Submissions1257443
Total Times Completed443957
JavaScript Completions136311
CoffeeScript Completions465
Ruby Completions10891
Clojure Completions1128
Python Completions146635
C# Completions31067
Java Completions51928
Haskell Completions3284
C++ Completions28142
Elixir Completions850
TypeScript Completions8480
PHP Completions8992
Swift Completions3001
Go Completions7075
Rust Completions5316
C Completions13654
R Completions729
Nim Completions97
F# Completions327
Scala Completions1186
Lua Completions629
Shell Completions622
PowerShell Completions333
Crystal Completions68
NASM Completions74
Julia Completions271
Kotlin Completions3332
Racket Completions144
Dart Completions2010
Factor Completions36
Prolog Completions69
Raku Completions34
COBOL Completions52
CommonLisp Completions148
D Completions28
VB Completions63
Groovy Completions16
Total Stars3582
% of votes with a positive feedback rating88% of 40240
Total "Very Satisfied" Votes31764
Total "Somewhat Satisfied" Votes7670
Total "Not Satisfied" Votes806
Ad
Contributors
  • jhoffner Avatar
  • OverZealous Avatar
  • curtmack Avatar
  • dnolan Avatar
  • Azuaron Avatar
  • fenra Avatar
  • Osmosis Avatar
  • Metal Wing Avatar
  • anter69 Avatar
  • lechevalier Avatar
  • Chrono79 Avatar
  • kazk Avatar
  • kleidemos Avatar
  • B1ts Avatar
  • CajetanP Avatar
  • Firefly2002 Avatar
  • calebkleveter Avatar
  • leometzger Avatar
  • user9040298 Avatar
  • rowcased Avatar
  • mentalplex Avatar
  • dolgov_vv Avatar
  • kdmatrosov Avatar
  • Bubbler Avatar
  • metagn Avatar
  • JavaCommons Avatar
  • bassopenguin Avatar
  • spudboy Avatar
  • hobovsky Avatar
  • user3029010 Avatar
  • Console Cowboy Avatar
  • uniapi Avatar
  • stellartux Avatar
  • tonylicoding Avatar
  • user8436785 Avatar
  • y0sik Avatar
  • ejini战神 Avatar
  • akar-0 Avatar
  • Kacarott Avatar
  • dfhwze Avatar
  • NikCSharp Avatar
  • Captain Quack Avatar
  • JavaScripts Avatar
Ad