Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 33 characters in body
Source Link
Leaky Nun
  • 50.6k
  • 6
  • 115
  • 291

Python 3, (削除) 69 (削除ここまで) 63(削除) 63 (削除ここまで) 59 bytes

4 bytes thanks to Dennis.

f=lambda n:n-1and max(j for j in range(1,n)if n%j<1)+f(n-1)or 0

Try it online! Try it online!

I set the recursion limit to 2000 for this to work for 1000.

Python 3, (削除) 69 (削除ここまで) 63 bytes

f=lambda n:n-1and max(j for j in range(1,n)if n%j<1)+f(n-1)or 0

Try it online!

I set the recursion limit to 2000 for this to work for 1000.

Python 3, (削除) 69 (削除ここまで) (削除) 63 (削除ここまで) 59 bytes

4 bytes thanks to Dennis.

f=lambda n:n-1and max(j for j in range(1,n)if n%j<1)+f(n-1)

Try it online!

I set the recursion limit to 2000 for this to work for 1000.

added 92 characters in body
Source Link
Leaky Nun
  • 50.6k
  • 6
  • 115
  • 291

Python 3, 69(削除) 69 (削除ここまで) 63 bytes

lambdaf=lambda n:sum(n-1and max(j for j in range(1,in)if i%j<1n%j<1)for i in range+f(2,n+1)n-1)or 0

Try it online! Try it online!

I set the recursion limit to 2000 for this to work for 1000.

Python 3, 69 bytes

lambda n:sum(max(j for j in range(1,i)if i%j<1)for i in range(2,n+1))

Try it online!

Python 3, (削除) 69 (削除ここまで) 63 bytes

f=lambda n:n-1and max(j for j in range(1,n)if n%j<1)+f(n-1)or 0

Try it online!

I set the recursion limit to 2000 for this to work for 1000.

Source Link
Leaky Nun
  • 50.6k
  • 6
  • 115
  • 291

Python 3, 69 bytes

lambda n:sum(max(j for j in range(1,i)if i%j<1)for i in range(2,n+1))

Try it online!

AltStyle によって変換されたページ (->オリジナル) /