Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #9 Sep 12 2017 10:00:08
%S 1,2,3,0,4,9,13,4,14,25,4,30,4,9,32,30,45,48,12,7,34,74,40,76,96,57,
%T 64,90,89,50,117,87,29,46,108,113,10,70,111,150,14,153,119,26,81,78,
%U 112,209,173,177,186,126,26,25,60,74,23,27,138,49,72,211,252,169
%N a(n) = (!0 + !1 + ... + !(p-1)) mod p, where p = prime(n).
%C !n is a subfactorial number (A000166).
%C This is A173184(p) mod p where p = prime(n) .
%H Michel Lagneau, <a href="/A258818/b258818.txt">Table of n, a(n) for n = 1..1000</a>
%e For n=3, prime(3) = 5 => !0 + !1 + !2 + !3 + !4 = 1 + 0 + 1 + 2 + 9 = 13 == 3 (mod 5), so a(3) = 3.
%p A:= proc(n) option remember; if n<=1 then 1-n else (n-1)*(procname(n-1)+procname(n-2)); fi; end;
%p a:=n->n!*sum((-1)^k/k!, k=0..n):
%p lf:=n->add(A(k), k=0..n-1); [seq(lf(ithprime(n)) mod ithprime(n), n=1..40)];
%t Table[Mod[Total[Subfactorial[Range[0, n-1]]], n], {n, Prime[Range[70]]}]
%Y Cf. A258817.
%K nonn
%O 1,2
%A _Michel Lagneau_, Jun 11 2015