Remainder of a function in two variables Supposed a function in two variables is defined as $f(a,b) = \frac{a(a-1)b^{2}}{2}$, and $a,b \in N$ where a is fixed on a certain value while b runs from 1 to n.
For instance,
$$f(4,1) = \frac{4(4-1)1^{2}}{2} = 6$$
$$f(4,2) = \frac{4(4-1)2^{2}}{2} = 24$$
$$f(4,3) = \frac{4(4-1)3^{2}}{2} = 54$$
$$f(4,4) = \frac{4(4-1)4^{2}}{2} = 96$$
$$f(4,5) = \frac{4(4-1)5^{2}}{2} = 150$$
I noticed that when I take the modulo of this functions in terms of $a$, I get
$$f(4,1) (mod \;4) =2$$
$$f(4,2) (mod \;4) =0$$
$$f(4,3) (mod \;4) =2$$
$$f(4,4) (mod \;4) =0$$
$$f(4,5) (mod \;4) =2$$
But the case is different if $a$ is odd number
$$f(3,1) (mod\; 3) = 0$$
$$f(3,2) (mod\; 3) = 0$$
$$f(3,3) (mod\; 3) = 0$$
$$f(3,4) (mod\; 3) = 0$$
$$f(3,5) (mod\; 3) = 0$$
Observation:

*

*If $a$ is odd, the remainder is always 0

*If $a$ is even, the remainder is a series of $\frac {a}{2}, 0, \frac {a}{2}, 0, \frac {a}{2}, ...$
Can you give me any idea regarding this?

When $a$ is odd, $\frac{a-1}2$ is an integer, so your fraction is $a\times\frac{a-1}2\times b^2$, which is an integer multiple of $a$, so it's equal to $0$ mod $a$.
When $a$ is even, $\frac a2$ is an integer, so your fraction is $\frac a2\times(a-1)b^2$. This is an integer multiple of $\frac a2$, so mod $a$ it can only be $0$ or $\frac a2$, depending on whether $(a-1)b^2$ is even or odd. Now $a-1$ is odd and $b$ alternates between odd and even as we increment it. As a result, $(a-1)b^2$ also alternates between odd and even, so your remainder alternates between $\frac a2$ and $0$.
