%I #15 Oct 20 2023 05:36:09
%S 1,3,5,7,9,11,13,14,15,17,19,21,22,23,25,27,28,29,30,31,33,35,37,38,
%T 39,41,43,45,46,47,49,51,52,53,55,57,59,61,62,63,65,66,67,69,70,71,73,
%U 75,77,78,79,81,83,85,86,87,89,91,92,93,94,95,97,98,99,101
%N Numbers n such that the sum of the distinct residues of x^n (mod n), x=0..n-1, is divisible by n.
%C All odd prime numbers are in the sequence.
%C The sum of the distinct residues is 0, 1, 3, 1, 10, 8, 21, 1, 9, 25, 55, 14, 78, 42, 105, 1, 136,.. for n>=1.
%e n= 14 is in the sequence because x^14 == 0, 1, 2, 4, 7, 8, 9, or 11 (mod 14), and the sum 0+1+2+4+7+8+9+11 = 42 is divisible by 14.
%p sumDistRes := proc(n)
%p local re,x,r ;
%p re := {} ;
%p for x from 0 to n-1 do
%p re := re union { modp(x^n,n) } ;
%p end do:
%p add(r,r=re) ;
%p end proc:
%p for n from 1 to 100 do
%p if sumDistRes(n) mod n = 0 then
%p printf("%d,",n);
%p end if;
%p end do: # _R. J. Mathar_, Oct 04 2011
%t sumDistRes[n_] := Module[{re = {}, x}, For[x = 0, x <= n-1, x++, re = re ~Union~ {PowerMod[x, n, n]}]; Total[re]];
%t Select[Range[100], Mod[sumDistRes[#], #] == 0&] (* _Jean-François Alcover_, Oct 20 2023, after _R. J. Mathar_ *)
%Y Cf. A195637.
%K nonn
%O 1,2
%A _Michel Lagneau_, Oct 03 2011
|