Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

Modulus Summation

Haskell, 22 bytes

f x=sum$mod x<$>[1..x]

Try it online!

Explanation

Yes.


Ruby, 28 27 23 bytes

-4 bytes thanks to @daniero.

->n{(1..n).sum{|i|n%i}}

Try it online!

Ruby, 28 bytes

f=->n{n>($.+=1)?n%$.+f[n]:0}

Try it online!


05AB1E, 3 bytes

L%O

Try it online!

Tags:

Sequence

Code Golf

Division

Related

Decode Factor Trees Duck, Duck, Josephus Electron Configuration The struggling college student's GPA Calculator The Missing Number - Version 2 It's a Slippery Slope Encode Factor Trees The Missing Number Revised Google's doodle on kids coding: shortest program solving all the levels How to improve Ruby code under some restrictions The Microwave Challenge Calculate the lowest number where the sum of the sequence of numbers exceeds a given value

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy