Skip to main content
added 103 characters in body
Source Link
tsh
  • 35.6k
  • 2
  • 34
  • 129

Python, 4544 bytes

lambda k:sum(i i*(k%i<1)for i in range(1,1+k)if k%i<1)

Thanks to Stephen, save 1 byte.

  • Thanks to Stephen, save 1 byte by removing whitespace.
  • Thanks to Jonathan Frech, save another 1 byte by changing if to multiply.

Python, 45 bytes

lambda k:sum(i for i in range(1,1+k)if k%i<1)

Thanks to Stephen, save 1 byte.

Python, 44 bytes

lambda k:sum(i*(k%i<1)for i in range(1,1+k))
  • Thanks to Stephen, save 1 byte by removing whitespace.
  • Thanks to Jonathan Frech, save another 1 byte by changing if to multiply.
added 33 characters in body
Source Link
tsh
  • 35.6k
  • 2
  • 34
  • 129

Python, 4745 bytes

lambda k:sum(i for i in range(1,1+k) if k%i==0k%i<1)

Thanks to Stephen, save 1 byte.

Python, 47 bytes

lambda k:sum(i for i in range(1,1+k) if k%i==0)

Python, 45 bytes

lambda k:sum(i for i in range(1,1+k)if k%i<1)

Thanks to Stephen, save 1 byte.

Source Link
tsh
  • 35.6k
  • 2
  • 34
  • 129

Python, 47 bytes

lambda k:sum(i for i in range(1,1+k) if k%i==0)