0

Can anyone tell where my code is wrong, this code runs 2 test cases , I was stuck the remaining test cases. Can anyone send code

This is the my code def fact(n): if(n>0 and n<3): return 1 return fact(n-fact(n-1))+fact(n-fact(n-2)) n=int(input()) print(fact(n))

19th Apr 2021, 12:54 PM
Gunti Daniel Kumar
Gunti Daniel Kumar - avatar
2 ответов
+ 2
Your function returns 1 if 2 is input but should be 2. It should return 1 only if the input is 1 or 0. This is assuming that "fact" is short for "factorial" and that is what you are trying to code. If not, then you'll need to mention the problem description.
19th Apr 2021, 1:43 PM
Russ
Russ - avatar
0
I was normally used fact function, this is not factorial programming ...
19th Apr 2021, 4:07 PM
Gunti Daniel Kumar
Gunti Daniel Kumar - avatar