1

Is the following true for all interger $n>1$?

GCD of $n$ and $\sum_{i=1}^{n} \chi_{n,1}(i) i^{-2} \bmod n$ is $\begin{cases}n&\text{if }3\nmid n,n\ne2^a\\ n&\text{if }3\mid n\text{ and }n\text{ has a prime factor of the form }3k+1\\ \frac n3&\text{if }3\mid n\text{ and }n\text{ has no prime factor of the form }3k+1\\ \frac n2&\text{if }n=2^a\end{cases}$
where $\chi _{m,1}(a)$ denotes the principal character mod $m$.

Example

For $n=5$, WA computes $\sum_{i=1}^{5} \chi_{5,1}(i) i^{-2} \bmod 5=10$, so $\gcd(5,10)=5=n$.

For $n=8$, WA computes $\sum_{i=1}^8 \chi_{8,1}(i) i^{-2} \bmod 8=4$, so $\gcd(8,4)=4=\frac{n}2$.

For $n=15$, WA computes $\sum_{i=1}^{15} \chi_{15,1}(i) i^{-2} \bmod 15=20$, so $\gcd(15,20)=5=\frac{n}3$.

For $n=21$, WA computes $\sum_{i=1}^{21} \chi_{21,1}(i) i^{-2} \bmod 21=84$, so $\gcd(21,84)=21=n$.

A050931 is numbers that has a prime factor of the form $3k+1$.


Formula

Since $\{i\bmod n:\gcd(i,n)=1\}=\{i^{-1}\bmod n:\gcd(i,n)=1\}$, we can replace $i^{-2}$ with $i^2$:$$\sum_{i=1}^{n} \chi_{n,1}(i) i^{-2} \bmod n=\sum_{i=1}^{n} \chi_{n,1}(i) i^2 \bmod n$$ By Möbius inversion formula $$\sum_{1\le i\le n\atop\gcd(i,n)=1}i^2 =\sum_{d|n}\mu(d)\sum_{1\le k\le \frac{n}{d}}d^2 k^2\\ =\frac{n}{6}\sum_{d|n}d\mu(d) \left(\frac{n}{d}+1\right)\left(\frac{2n}{d}+1\right)\\ =\frac{n}{6}\sum_{d|n}\frac{d^2+3dn+2n^2}{d}\mu(d)\\ =\frac{n}{6}\sum_{d|n}d\mu(d)+\frac{n^2}{3}\sum_{d|n}\frac{n}{d}\mu(d)\\ =\frac{n}{6}\prod_{\text{prime }p|n}(1-p)+\frac{n^2}{3}\varphi(n)$$

hbghlyj
  • 5,361

1 Answers1

1

If $3\nmid n$ and $n\ne2^a$, then $3\bmod n$ is invertible, so $\frac{n}3\equiv0\pmod n$, and $n$ has an odd prime factor, so $2\mid\prod_{\text{prime }p|n}(1-p)$, so $$\sum_{1\le i\le n\atop\gcd(i,n)=1}i^2=\frac{n}{3}\left(\frac{\prod_{\text{prime }p|n}(1-p)}2+n\varphi(n)\right)\equiv0\pmod n$$ so $\gcd(n,\sum_{1\le i\le n\atop\gcd(i,n)=1}i^2)=n$.

If $3\mid n$, then $n\mid\frac{n^2}{3}$, $$\sum_{1\le i\le n\atop\gcd(i,n)=1}i^2\bmod n=\frac{n}{6}\prod_{\text{prime }p|n}(1-p)\bmod n\\ =-\frac{n}{3}\prod_{\substack{\text{prime }p|n\\p\ne3}}(1-p)\bmod n\\ =\cases{0&if $n$ has a prime factor of the form $3k+1$\\ \pm\frac{n}3&if $n$ has no prime factor of the form $3k+1$}$$ so $\gcd(n,\sum_{1\le i\le n\atop\gcd(i,n)=1}i^2)=\cases{n&if $n$ has a prime factor of the form $3k+1$\\\frac{n}3&if $n$ has no prime factor of the form $3k+1$}$

If $n=2^a$,$$\sum_{1\le i\le n\atop\gcd(i,n)=1}i^2=\frac{4^a-1}{3}2^{a-1}=(1+4+\dots+4^{a-1})2^{a-1}\\\equiv2^{a-1}\pmod{2^a}$$ so $\gcd(n,\sum_{1\le i\le n\atop\gcd(i,n)=1}i^2)=2^{a-1}=\frac{n}2$.

hbghlyj
  • 5,361