Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Oh! i understand it now. May be my understanding of closed form is different, may be even wrong. What I searching for is to represent $K$ as a function of $n$, $N$ and some $f(N_i)$. An example would be the sum of natural number 1+2+3+ ... n = n(n+1)/2, a formula where I can avoid running through the numbers to compute the sum. Is something like this possible?
@StevenClark $M \neq \sum_{i=1}^n N_i$, but it is the sum of remainders $M = \sum_{i=1}^n N_i \% N$. Also, $N$ has no relation to $N_i$, so there is no such restriction as $0 < N_i < N$.
@StevenClark I have modified the question to reduce confusions, wrt random. Please let me know if this clarifies your doubts. Distinct implied $N_i \neq N_j$, which is optional, just in case it helped to arrive at a solution quicker. $N$ can be any other number either inside or outside the set of {$N_i$} and $M$ is just the representation of the actual sum.