I am trying to understand this function that I am debugging:
static int a = 1;
static int[] functionModulus(int n)
{
for (; n % ++a > 0; ) ;
return new[] {n = n/a + a >> 1, n - a};
}
Basically this function is a computation of getting an input, and will return an array with two elements such that a^2 - b^2 = n (input n). So an input of n = 15, will return 4 and 1 since 4^2 - 1^2 = 15.
Nevermind the computations, I wonder how does this exact line works:
for (; n % ++a > 0; ) ;
While debugging, the value of a at the start is 1, and my input of n = 15.
Which of course a was initialize to 1 outside the function, and 15 is my input of n. What I am puzzled is after stepping out of the for loop, the value of a becomes 3? How does it become 3? 15 mod of 3 is not greater than zero? I tried to change n to 21, and a still becomes 3 after stepping out the for loop? I cannot really understand how does it increments to 3 and how does this works.