How to debug it?

def f(n, m):
    while f(n, m) != int(f(n, m)):
        if n == 1:
            return 1
        elif n >= m - 1:
            return 0
        elif n >= 2 and n != m - 1:
            f(n, m+1) = f(n-1, m) + f(n, m) + f(n+1, m)
print(f(2, 4))

In console it appear error here

File "compiler.py", line 8 f(n, m+1) = f(n-1, m) + f(n, m) + f(n+1, m) ^ SyntaxError: can't assign to function call

2

There are 2 answers

0
Shambhav On

You are writing

f(n, m+1) = f(n-1, m) + f(n, m) + f(n+1, m)

f(n, m + 1) is not a variable, it's a call for a function. I don't know what you are trying to achieve here with this weird code.

0
God_ppt On

I know it now just

  def f(n, m):
      if n == 1:
          return 1
      elif n > m:
          return 0
      else:
          return f(n-1, m-1 ) + f(n, m-1 ) + f(n+1, m-1 )
  print(f( 98, 100 ))