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

Commonmark migration
Source Link

#Python 2, (削除) 54 (削除ここまで) 46 bytes

Python 2, (削除) 54 (削除ここまで) 46 bytes

This is a very very very! fast, iterative solution.

n=r=input();k=2
while k<n:r=r*n+k;k+=1
print r

Try it online

There's no recursion, so it works for large input. Here's the result of n = 17000 (takes 1-2 seconds):

http://pastebin.com/UZjgvUSW

#Python 2, (削除) 54 (削除ここまで) 46 bytes

This is a very very very! fast, iterative solution.

n=r=input();k=2
while k<n:r=r*n+k;k+=1
print r

Try it online

There's no recursion, so it works for large input. Here's the result of n = 17000 (takes 1-2 seconds):

http://pastebin.com/UZjgvUSW

Python 2, (削除) 54 (削除ここまで) 46 bytes

This is a very very very! fast, iterative solution.

n=r=input();k=2
while k<n:r=r*n+k;k+=1
print r

Try it online

There's no recursion, so it works for large input. Here's the result of n = 17000 (takes 1-2 seconds):

http://pastebin.com/UZjgvUSW

added 6 characters in body
Source Link
mbomb007
  • 23.6k
  • 7
  • 66
  • 143

#Python 2, 54(削除) 54 (削除ここまで) 46 bytes

This is a veryveryvery! fast, iterative solution.

lambda n:n**~-n+sum(n**~-i*n=r=input(n-i)for i;k=2
while ink<n:r=r*n+k;k+=1
print range(1,n-1))r

Try it online Try it online

There's no recursion, so it works for large input. Here's the result of n = 17000 (takes 1-2 seconds):

http://pastebin.com/UZjgvUSW

#Python 2, 54 bytes

This is a very fast, iterative solution.

lambda n:n**~-n+sum(n**~-i*(n-i)for i in range(1,n-1))

Try it online

There's no recursion, so it works for large input. Here's the result of n = 17000:

http://pastebin.com/UZjgvUSW

#Python 2, (削除) 54 (削除ここまで) 46 bytes

This is a veryveryvery! fast, iterative solution.

n=r=input();k=2
while k<n:r=r*n+k;k+=1
print r

Try it online

There's no recursion, so it works for large input. Here's the result of n = 17000 (takes 1-2 seconds):

http://pastebin.com/UZjgvUSW

Source Link
mbomb007
  • 23.6k
  • 7
  • 66
  • 143

#Python 2, 54 bytes

This is a very fast, iterative solution.

lambda n:n**~-n+sum(n**~-i*(n-i)for i in range(1,n-1))

Try it online

There's no recursion, so it works for large input. Here's the result of n = 17000:

http://pastebin.com/UZjgvUSW

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