Have you tried using Trace?
It would help to be able to copy your code. When posting, please try to include your code instead of a picture of your code.
If you cannot find a general formula, maybe you can use integer relation detection to try experimentally finding one? I've never gotten it to work in real life myself.