ok, sorry, in this module it seems - we use builtin integers, not sympy's Integer.
So, please change back S.Zero -> 0 (and remove S import).

Also, you should convert function argument to builtin integer with:
```python
n = as_int(n)
```