1
$\begingroup$

Let $N,a,b$ be positive integers with $a$ and $b$ coprime to each other.

I can sum up $\sum\lfloor ia/b\rfloor$ (for $i$ from $1$ till $N$) by counting lattice points in a right triangle. This sum can be computed recursively in $O(\log(\max(N,a,b)))$ time.

Is there a similar way to compute $\sum i (i \lfloor a/b\rfloor)$? I am solving some problems for a competition and being computing this sum will simplify my calculations greatly.

  • 2
    The sum in the title is not the sum in the body. Which one do you really want?2012-08-08

0 Answers 0