I faced question below in py challenge. So i ran the code in sololearn compiler. The output was 34. Why? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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 Respostas
+ 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