Factorial CHALLANGE | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

19th Dec 2017, 9:10 PM
Alex_Joo
Alex_Joo - avatar
31 Answers
20th Dec 2017, 3:50 AM
Louis
Louis - avatar
+ 26
https://code.sololearn.com/cPPGIaXLb8e7/?ref=app
1st Mar 2018, 8:27 PM
Danijel Ivanović
Danijel Ivanović - avatar
1st Mar 2018, 8:25 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 23
https://code.sololearn.com/cha99rgulGmE/?ref=app
20th Dec 2017, 5:55 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
21st Dec 2017, 6:22 PM
LukArToDo
LukArToDo - avatar
+ 15
https://code.sololearn.com/cp1UNm7yaxMu/?ref=app
20th Dec 2017, 4:47 AM
qwerty
qwerty - avatar
20th Dec 2017, 11:22 AM
Käzî Mrîdùl Høssäîn
Käzî Mrîdùl Høssäîn - avatar
20th Dec 2017, 1:23 PM
Justine Ogaraku
Justine Ogaraku - avatar
+ 12
https://code.sololearn.com/c9U7NM6WT8q4/?ref=app
20th Dec 2017, 6:14 PM
GAWEN STEASY
GAWEN STEASY - avatar
20th Dec 2017, 6:23 PM
Ferhat Sevim
Ferhat Sevim - avatar
+ 10
https://code.sololearn.com/cu8uHv5XB2RR/?ref=app
28th Dec 2017, 1:18 AM
Kulanga Kaushani
Kulanga Kaushani - avatar
20th Dec 2017, 5:28 AM
Marfik Em
Marfik Em - avatar
+ 8
https://code.sololearn.com/ceaw76y9q4jz/?ref=app
20th Dec 2017, 1:13 PM
Kulanga Kaushani
Kulanga Kaushani - avatar
+ 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
20th Dec 2017, 8:44 PM
bedawang
bedawang - avatar
20th Dec 2017, 8:24 PM
Luc Hariman Randrianomenjanahary
Luc Hariman Randrianomenjanahary - avatar
+ 6
my try :) https://code.sololearn.com/cV9p8IOnjtCM/ EDIT: V2 different approach, sould be much faster :) https://code.sololearn.com/chgx5Y8uV971/
26th Dec 2017, 10:43 PM
Karol Gašparík
Karol Gašparík - avatar
+ 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.
20th Dec 2017, 5:03 AM
John Miller
John Miller - avatar
+ 4
https://code.sololearn.com/cghCd97518YH/?ref=app
21st Dec 2017, 2:17 AM
Rabee Abbas
Rabee Abbas - avatar
24th Dec 2017, 3:45 PM
Roy
Roy - avatar