Here I have a series for N=2 -> 1,2,3,4,5,6,7,8,9,10 and the series continues
for N=3 -> 0,1,1,2,2,3,3,4,4,5,5,6,6 and the series continues
for N=4 -> 0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5 and the series continues
I have already tried using different formulas but I can't make a definite formula which hold for every given N and K. The Constraints on N and K are: N ranges from 2 to 10^18 and K ranges from 1 to 10^18
So you have $$K=1+i(N-1)+j,$$ $j\in\{0,1,..,N-2\}$ where $i,j$ can be computed using integer division and remainder. Then the sum is by the basic summation formula of the first integers $0,1,...,i$ and the remaining $j$ instances of the sequence elements $i+1$ $$ (N-1)\frac{i(i+1)}2+j(i+1). $$