Why do we add mod

if m>=n then f(m+2)>f(n+1) which makes f(m+2)-f(n+1) always postive why do we add mod in the end

hello @coe17b014
yeah i totally agree with u but u missed one thing.
we cannot say anything about these two values
f(m+2)%mod , f(n+1)%mod
f(m+2)%mod can be greater than f(n+1)%mod or vice a versa
thats why while subtracting we using mod property.
(a-b)%c=(a-b+c)%c

also why we are taking mod with f(m+1)?
it is because f(m+1) can be a very big number( bigger than range of long long) thats the reason for taking mod

1 Like