Factorial CHALLANGE | Sololearn: Learn to code for FREE!

+13

Factorial CHALLANGE

Hi! This challenge is about factorial operation. This is then your number starting multiply it self from one to it self. like: 5! = 1*2*3*4*5 = 120 or 6! = 1*2*3*4*5*6 = 720 Write a calculator or something like i did in other languages. https://code.sololearn.com/Wo2A2Zg0cFMP/?ref=app

12/19/2017 9:10:51 PM

Alex_Joo

30 Answers

New Answer

+7

Recursive Lambda https://code.sololearn.com/cb60vmKFbNLk/?ref=app Non-Recursive https://code.sololearn.com/cspGL8hL6tQk/?ref=app Non-Recursive Lambda with eval (oneliner) ***BEST*** https://code.sololearn.com/cTL9Erz40lhW/?ref=app

+26

https://code.sololearn.com/cPPGIaXLb8e7/?ref=app

+25

https://code.sololearn.com/cKZcce9eWm3c/?ref=app

+23

https://code.sololearn.com/cha99rgulGmE/?ref=app

+16

https://code.sololearn.com/cT5eBID3o6Gn/?ref=app

+15

https://code.sololearn.com/cp1UNm7yaxMu/?ref=app

+14

https://code.sololearn.com/cyx312A2q71R/?ref=app

+14

Here!! https://code.sololearn.com/c5ss4Ey3W2DN/?ref=app

+12

https://code.sololearn.com/c9U7NM6WT8q4/?ref=app

+10

https://code.sololearn.com/cNQ149MaJKfb/?ref=app

+10

https://code.sololearn.com/cu8uHv5XB2RR/?ref=app

+8

https://code.sololearn.com/c19AAubq4m9W/?ref=app

+8

https://code.sololearn.com/ceaw76y9q4jz/?ref=app

+8

Ruby: (1..n).inject(:*) || 1 https://code.sololearn.com/cJXhhv3Thov2/ edit: code has been corrected so it also returns the right answer when negative numbers are given

+6

https://code.sololearn.com/Wxk7KL58inWk/?ref=app

+6

my try :) https://code.sololearn.com/cV9p8IOnjtCM/ EDIT: V2 different approach, sould be much faster :) https://code.sololearn.com/chgx5Y8uV971/

+5

Most simply: from math import factorial print(factorial(int(input()))) Or written out for clarity, a recursive function: Simple Factorial https://code.sololearn.com/cwiswHNQz0lE/?ref=app Remember that 0! = 1 and negative factorial is undefined. Many of the other programs return these two conditions incorrectly.

+4

https://code.sololearn.com/cDO15j6FTfpn/?ref=app

+4

https://code.sololearn.com/cghCd97518YH/?ref=app

+4

https://code.sololearn.com/cl86DxFZLTMj