6 kyu

Sum of many ints

55 of 2,965farzher

Description:

Write this function

for i from 1 to n, do i % m and return the sum

f(n=10, m=5) // returns 20 (1+2+3+4+0 + 1+2+3+4+0)

You'll need to get a little clever with performance, since n can be a very large number

Mathematics
Algorithms

Stats:

CreatedJan 24, 2015
PublishedJan 24, 2015
Warriors Trained7931
Total Skips1424
Total Code Submissions34702
Total Times Completed2965
CoffeeScript Completions55
JavaScript Completions1202
Haskell Completions303
Python Completions1242
Ruby Completions269
R Completions39
Objective-C Completions30
COBOL Completions9
Total Stars219
% of votes with a positive feedback rating89% of 351
Total "Very Satisfied" Votes296
Total "Somewhat Satisfied" Votes36
Total "Not Satisfied" Votes19
Ad
Contributors
  • farzher Avatar
  • jhoffner Avatar
  • bkaes Avatar
  • JS01 Avatar
  • GiacomoSorbi Avatar
  • donaldsebleung Avatar
  • Voile Avatar
  • mentalplex Avatar
  • user8436785 Avatar
  • akar-0 Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad