¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita0
Recursion?🤔dynamic programmming???🙃🙂
def manu(x): if x == 1: return 0 if x == 2: return 1 else: return manu(x - 1) + manu(x - 2) print(manu(10)) 34 is the answer when we execute this code snippet in any IDE.Can geeks tell me how do we get that?(i feel like we should use dynamic programming concept here but still want to sense that with ur good procedure) Hoping ur answers......
1 Respuesta
+ 2
For ex: manu(5) : returns
=> manu(5-1) + manu(5-2)
=> manu(4) + manu(3)
=> manu(4-1)+manu(4-2)+manu(3-1) +manu(3-2)
=>manu(3)+manu(2) + manu(2) + manu(1)
=>manu(3-1)+manu(3-2) + manu(2) +1+0
=> manu(2) + manu(1) + 1 +1
=> 1 + 0 + 1 +1
=> 3
Simalar way for 10.