0

I faced question below in py challenge. So i ran the code in sololearn compiler. The output was 34. Why?

What is the output of this code? def rec(n): n%5 if n<=1: return n else: return rec(n-1)+rec(n-2) print(rec(9)) The answer in challenge was: 3 by Александр Громозонов

28th Dec 2020, 9:03 PM
Hushnudbek
Hushnudbek - avatar
2 Respuestas
+ 3
Should it maybe be: n%=5 instead of: n%5 which doesn't change anything? Then the answer would be 3.
28th Dec 2020, 9:12 PM
ChaoticDawg
ChaoticDawg - avatar
0
Yeah. I'm so sorry, it's my mistake, thank you very much.
29th Dec 2020, 7:29 AM
Hushnudbek
Hushnudbek - avatar