you can get a solution with complexity $\mathcal O (1)$
there are $5$ types of solutions:
- All numbers are equal
- three equal numbers and one distinct
- two and two
- one pair and the other two distinct
- all different
let $A,B,C,D,E$ be the number of solutions of each type.
Clearly $A=1$ if $4|N$ and $0$ otherwise.
We have $B=\lfloor (N-1)/3 \rfloor-A$
we have $C=0$ if $C$ is odd and $C=(N/2-1-A)/2$ otherwise.
We have $D=[(\sum\limits_{i=1}^{2i<N}N-2i-1)-C]/2-B$.
Finally, using stars and bars we get $E=\frac{\binom{N-1}{3}-A-4B-6C-12D}{4!}$.
And clearly you want $A+B+C+D+E$
We want to find the number of solutions of
$$n+(n+1)+\ldots + (n+k) = 1050,\ n\in\mathbb Z_{>0},\ k\in\mathbb Z_{\geq 0}.\tag{1}$$
Rewrite the sum as $$n(k+1) + 0 + 1 +\ldots + k = n(k+1) + \frac{k(k+1)}{2}= \frac 12(2n+k)(k+1).$$
Thus, the number of solutions to $(1)$ is the same as the number of solutions of
$$(2n+k)(k+1) = 2100,\ n\in\mathbb Z_{>0},\ k\in\mathbb Z_{\geq 0}.\tag{2}$$
Let $a$ and $b$ be divisors of $2100$ such that
\begin{align}
2n+k &= a,\\
k+1 &= b.\tag{3}
\end{align}
Solving it we get
\begin{align}
n &= \frac{a-b+1}2,\\
k &= b -1.\tag{4}
\end{align}
From here we see that not every choice of integers $a$ and $b$ such that $ab = 2100$ will give us a solution to $(2)$. Since $a-b+1$ must be even, $a$ and $b$ are of opposite parities. Also, $a\geq b > 0$ since $n> 0$ and $k \geq 0$.
First determine the number of ways to factor $2100 = 2^2\cdot 3\cdot 5^2 \cdot 7$ such that one of the factors is odd. For this to be fulfilled, we shouldn't allow $4 = 2^2$ to be factored, so consider $2100 = 4\cdot 3 \cdot 5^2 \cdot 7$ instead. Thus, there are $2\cdot 2\cdot 3\cdot 2 = 24$ positive integral solutions to $2100 = a'b'$ such that one factor is odd. Because of commutativity, it means there are $12$ distinct ways to factor $2100$ into product of two factors, one of which is odd, and for every such factorization there is a unique choice for $a$ and $b$ such that $a\geq b$.
Thus, there are $12$ positive integral solutions to $(2)$.
Best Answer
Yes, there is such a formula (assuming $k$ and $n$ are natural numbers).
In order to find it, I suggest you the following:
Those sequences are easy to count: