+ 3
Shortest code challenge
what will be the shortest code for the factorial
5 odpowiedzi
+ 2
can be it in a single line
+ 1
f=lambda i:+(i<2) or i*f(i-1)
https://code.sololearn.com/czAFSwbs9SAE/?ref=app
- 1
https://code.sololearn.com/cd68VTjfTfkN/?ref=app
- 1
Factorial itself can be in one line. I'll post the code when I figure out how to make cin output directly to function parameter without making a variable.
- 1
https://code.sololearn.com/c3v4kQUBxGBO/?ref=app
https://code.sololearn.com/c3SyOGlMgthN/?ref=app
I am aware I could stack some lines in main, but it would only hide I couldn't come up with a way to shorten the input. Second one is just with all unnecessary characters removed and one cheeky change to save 1 character.