Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
lambda n:(r:=range(2,n+1),[math[i-~math.prodfactorial(rn)+i for i in r]range(1,n)[1]] import math
Try it online!Try it online!
Edit: changed math.prod to math.factorial, thanks to @l4m2
math.prod
math.factorial
lambda n:(r:=range(2,n+1),[math.prod(r)+i for i in r])[1] import math
Try it online!
lambda n:[i-~math.factorial(n)for i in range(1,n)] import math