Project Euler 340 - Crazy Functions

Official link: https://projecteuler.net/problem=340

Thought Process

It is clear that recursion will not work, we need to somehow simplify F(n) and S(n)

I noticed the following:

All that is left is to figure out a smart way to calculate S(a, b, c). Notice that we can break it up into the different k's.

Then we just need to sum the remaining terms and we are done!

Interactive Code

Enter 3 number separated (a, b, c)

Code will output S(a, b, c) mod 10^9