How to get the factorial of any number without using * (multiplication) operator? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

How to get the factorial of any number without using * (multiplication) operator?

Developed program in any language to get the factorial of any number but without using multiplication (*) operator.

13th Jul 2018, 5:11 AM
Mahesh Sanjay Tirmali
Mahesh Sanjay Tirmali - avatar
3 Réponses
0
In Python 3, fac = lambda x: 1 if x == 1 else sum([x for i in range(fac(x-1))]) print(fac(5)) Output: 120 Note: I don't take credit for this. I codegolfed code I found on Stack Overflow https://stackoverflow.com/questions/28005700/how-can-i-make-a-recursive-factorial-without-using-multiplication
13th Jul 2018, 5:34 AM
Satyam
0
replace n*x with n times of +x
13th Jul 2018, 9:52 AM
Микола Федосєєв
Микола Федосєєв - avatar
23rd Jan 2020, 6:06 AM
Deepak Sharma
Deepak Sharma - avatar