So currently I'm trying to solve this sum $$\sum_{i=1}^{2024} \gcd(i,8)$$
I decided to split it up into a couple of cases:
Case 1: $i$ is coprime to $8$
Well then $\gcd(i,8)=1$ for that $i$ correct? After some digging I find that there are $882$ numbers that are coprime to $8$ from $1 \leq i \leq2024$ using the technique in this post.
Now moving on I focused on the cases where $i$ is not coprime to $8$ . I noticed that there is a sort of cyclic pattern in the $\gcd(i,8)$. The pattern is like \begin{array}{|c|c|} \hline i & \gcd(i,8)\\\hline 2 & 2 \\ \hline 4 & 4 \\ \hline 6 & 2 \\ \hline 8 & 8 \\ \hline 10 & 2 \\ \hline 12 & 4 \\ \hline 14 & 2 \\ \hline 16 & 8 \\ \hline 18 & 2 \\ \hline ... & ... \\ \hline 2022 & 2 \\ \hline 2024 & 8 \\ \hline \end{array}
Case 2: when $i$ is such that $\gcd(i,8)=2$
Since there are $\lfloor \frac{2025}{2} \rfloor = 1012$ numbers that generate that thus the sum for those are $2(1012)=2024$.
Case 3: when $i$ is such that $\gcd(i,8)=4$
After some digging I found there are $253$ $i$'s that generate those, so the sum is $4(253)=1012$
Case 4: when $i$ is such that $\gcd(i,8)=8$
Again after some digging I found there are again $253$ $i$'s, so the sum will be $8(253)=2024$
Now I think I got all the cases, thus summing all of them up I got $882+2024+1012+2024=5942$. I'm confused since after looking at wolframalpha it seems the answer is $5060$, what was the thing I did that was false here? Can anyone point it out and correct it?