Prove that $W(n,\sum_{k=1}^{n}k^{2})=2(n-1)$ Let $F_{a}(n)$ be the digit sum of $n$ in base $a$,
define $W(a,b)=F_{a}(a^{\lceil\frac{\log{b}}{\log{a}}  \rceil}-b)$,
prove that $\displaystyle\ W(n,\sum_{k=1}^{n}k^{2})=2(n-1)$ if $n−1 \in 6\mathbb{N} \pm 1$.
 A: Let
\begin{align}
&a=n&
&b=\sum_{k=1}^nk^2=\frac{n(n+1)(2n+1)}6
\end{align}
We have
$$\frac{a^3}3\leq b\leq\frac{a^3}3+a^2$$
from which
$$2<\frac{\log(b)}{\log(a)}<3$$ hence $\lceil\log(b)/\log(a)\rceil=3$ and $W(a,b)=F_a(a^3-b)$.
Moreover, if $b=d_0+d_1a+d_2a^2$ with $0\leq d_i\leq a-1$ then
$$a^3-b=(a-d_0)+(a-d_1-1)a+(a-d_2-1)a^2$$
Since $a\nmid b$, we have $d_0\neq 0$, hence
\begin{align}
W(a,b)
&=(a-d_0)+(a-d_1-1)+(a-d_2-1)\\
&=3a-(d_0+d_1+d_2)-2\\
&=3n-2-F_n(b)
\end{align}
and it remains to show $F_n(b)=n$.
If $n=6q$, then $b=q+(3q)n+(2q)n^2$, hence $F_n(b)=q+3q+2q=6q=n$.
If $n=6q+2$, then $b=(1+3q)+qn+(1+2q)n^2$, hence $F_n(b)=(1+3q)+q+(1+2q)=2+6q=n$.
A: For positive integers $n,k$, let
$$S(n,k)=\sum_{i=1}^{n}i^k$$
and for positive integers $m,b$, with $b>1$, let $D(b,m)$ be the sum of the base-$b$ digits of $m$.
Let $k=2$.
Thus, suppose $a$ is a positive integer such that $a \mid S(a,2)$, and let $b=a+1$.
Identically, we have
$$
S(n,2)
=
\sum_{i=1}^n i^2
=
\frac{n(n+1)(2n+1)}{6}
$$
hence
\begin{align*}
&a \mid S(a,2)\\[4pt]
\implies\;&a{\;|}\left(
\frac{a(a+1)(2a+1)}{6}
\right)\\[4pt]
\implies\;&6 \mid \left((a+1)(2a+1)\right)\\[4pt]
\implies\;&6 \mid \left(b(2b-1)\right)\\[4pt]
\implies\;&6 \mid b\;\;\text{or}\;\;\Bigl(2 \mid b\;\;\text{and}\;\;3 \mid (2b-1)\Bigr)\\[4pt]
\end{align*}
If $6 \mid b$, then
\begin{align*}
S(b,2)&=\frac{b(b+1)(2b+1)}{6}\\[4pt]
&=\frac{b^3}{3}+\frac{b^2}{2}+\frac{b}{6}\\[4pt]
&=
\left({\small{\frac{b}{3}}}\right)\!{\cdot}\,b^2 
+
\left({\small{\frac{b}{2}}}\right)\!{\cdot}\,b^1
+ 
\left({\small{\frac{b}{6}}}\right)\!{\cdot}\,b^0
\end{align*}
hence
$$
D(b,S(b,2))
=
\left({\small{\frac{b}{3}}}\right)
+
\left({\small{\frac{b}{2}}}\right)
+
\left({\small{\frac{b}{6}}}\right)
=
b
$$
If $2 \mid b$ and $3 \mid (2b-1)$, then $b\equiv 2 \pmod3$, so
\begin{align*}
S(b,2)&=\frac{b(b+1)(2b+1)}{6}\\[4pt]
&=\frac{b^3}{3}+\frac{b^2}{2}+\frac{b}{6}\\[4pt]
&=
\left({\small{\frac{b+1}{3}}}\right)\!{\cdot}\,b^2 
+
\left({\small{\frac{b-2}{6}}}\right)\!{\cdot}\,b^1
+ 
\left({\small{\frac{b}{2}}}\right)\!{\cdot}\,b^0
\end{align*}
hence
$$
D(b,S(b,2))
=
\left({\small{\frac{b+1}{3}}}\right)
+
\left({\small{\frac{b-2}{6}}}\right)
+
\left({\small{\frac{b}{6}}}\right)
=
b.
$$
Thus, for all subcases, we have $D(b,S(b,2))=b$.
So we are considering the summation $\sum_{i=1}^a i^2$ in base $a$. A quick observation yields
$$
a^{2+1} = \sum_{i=1}^a a^2 \geq \sum_{i=1}^a i^2 \geq a^2.
$$
See $W(b,S(b,2))=D(b,b^3-S(b,2))$
$\implies W(b,S(b,2))=3a+1-D(b,S(b,2))=2a$
and also note $a\in \{6t\pm 1\}$ then $a|S(a,2)$
