In APIO 2019, For problem A In this solution it says that,

*Let f(x) = {(x + x / b) % a, x % b}*

*It's possible to prove that f(x) is periodic with smallest period = ab / gcd(a, b + 1)*

How do i find this (period of `f(x)`

)? I tried googling "how to find the period of a periodic function" but i could only find articles about trigonometric functions.

Any help is highly appreciated. Thank you for your time.

*I have asked this here but i didn't get any answer.*