I\'m stuck here. For n = 5
and k = 3
, the answer should be 19
. If I set k = 3
separately as a local or global variable and ru
Calling the function with wabbits(5)
will not work because the function is declared to accept 2 parameters: n
and k
. Both must be supplied.
You can call the function with two arguments, but the trouble is that the recursive call to wabbits()
passes only a single argument:
wabbits(n-2) * k + wabbits(n-1)
This is two calls to wabbits()
the first has one argument n-2
and the second also has only one argument n-1
. Since wabbits()
must be called with two arguments a TypeError` exception is raised as you observed.