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.