Can anyone explain this weird behavior ??

(correct one has accepted submission)

problem https://www.hackerrank.com/challenges/sherlock-and-permutations/problem

why this line is **wrong**

**((fact[n] % mod) * ((mul[k] % mod) * (mul[n - k] % mod)) % mod) % mod;**

submission https://www.hackerrank.com/challenges/sherlock-and-permutations/copy-from/177307265

and this is **correct**

**(fact[n] % mod * (mul[k] % mod * mul[n - k] % mod) % mod) % mod;**

submission https://www.hackerrank.com/challenges/sherlock-and-permutations/copy-from/177308369

while in this problem https://www.hackerrank.com/challenges/summing-the-n-series/problem

this is **correct**

**((n % mod) * (n % mod)) % mod**

submission https://www.hackerrank.com/challenges/summing-the-n-series/copy-from/177301822

and this is **wrong**

**(n % mod * n % mod) % mod**

submission https://www.hackerrank.com/challenges/summing-the-n-series/copy-from/177301360

I only applied the bracket to make it cleaner.

is the problem on their side ??