•Define $S(a,m)=1^m+2^m+3^m+...+a^m$ where $a,m\in\mathbb{Z}_+$
•Define $$f(m)=\sum_{S(a-1,m)\equiv -1\pmod a}1$$
Question
1) how to prove, For $m$ is odd, $f(m)=2$ and $a\in\{1,2\}$?
2) what is closed form to calculate $f(m)$ when $m$ is even?
Example $f(2)=3$ and $a\in\{1,2,3\}$
Edit:
I observed $a$ only belongs to $1$, prime number and Giuga number. e.g. $f(4)=5$ and $a\in\{1,2,3,5,30\}$ here $30$ is first Giuga number and $a$ also have it's prime factor.see, in $m=4,a$ have $2,3,5$ which prime factor of $30$. I also observed Carmichael number not belongs to $a$
Let $G$ denotes Giuga number and $p_1,p_2,...,p_n$ it's prime factors. e.g.$G=\prod p_i$
Statment (claim)
For some $m$, $p_i\in a \iff G\in a$.
Means $S(G-1,m)\equiv -1\pmod G\iff S(p_i-1,m)\equiv -1\pmod {p_i}$
Second edit: half solution for 2nd Q.
For $m$ is even $$S(p-1,m)\equiv \{0,-1\}\pmod p$$
$$S(p-1,m)\equiv -1\pmod p\implies p-1\mid m$$
$$\sum_{S(p-1,m)\equiv -1\pmod p}1= \sum_{p-1\mid m}1$$
By the above observation, if $a$ contains prime s.t prime factor of such giuga number then Giuga number also in set $a$.
So $f(m)=1+ \sum_{p-1\mid m}1+$ number of $G$ which generates by $p$.
Source code
n1= 1
o = 1
while n1 < 1000:
m = 2
num=n1
sum_num = 0
for i in range(1, num):
sum_num += i**(m)
n2 = (sum_num)
if((n2+1)%num == 0):
print(n1,"diviasible")
n1 += o