Question:
let $n$ is give odd positive integer numbers,and $a_{i}\neq 1,0\le a_{i}\le n-1$, and $$2^i\equiv a_{i}\pmod n,i=1,2,\cdots,m-1$$
where $m(m\le n)$ such $2^m\equiv 1\pmod n$
Find the sum $$S=\sum_{i=1}^{m}(-1)^{a_{i}}\cdot 2^{m-i}$$
My try: since $$2^m\equiv 1\pmod n\Longrightarrow m=\phi{(n)}$$
and for example
when $n=3$, it is clear $m=2$,so $$\sum_{i=1}^{m}(-1)^{a_{i}}2^{m-i}=(-1)^2\cdot 2^{2-1}+(-1)^1\cdot 2^{2-2}=2-1=1$$
when $n=5$, it is clear $m=4$,so $$\sum_{i=1}^{m}(-1)^{a_{i}}2^{m-i}=(-1)^2\cdots 2^{4-1}+(-1)^4\cdot 2^{4-2}+(-1)^3\cdot 2^{4-3}+(-1)^1\cdot 2^{4-4}=8+4-2-1=9$$
when $n=7$,It is clear $m=3$,then $$\sum_{i=1}^{m}(-1)^{a_{i}}\cdot 2^{m-i}=(-1)^2\cdot 2^{3-1}+(-1)^4\cdot 2^{3-2}+(-1)^1\cdot 2^{3-3}=4+2-1=5$$
and so on
But for general ,I can't.This problem is from a competition in china 2013
Thank you for you help.