%I #13 Mar 16 2023 08:50:27
%S 5,101,4421,1226280710981,115578717622022981,
%T 32656499591185747972776747396512425885838364422981,
%U 136372385605079432248118270297843987319730859689490659519593045108637838364422981
%N Primes in the sequence f(n+1) = f(n)+((-1)^(n+1))*n!, with f(1)=0.
%C The tenth term has 1579 digits. - _Harvey P. Dale_, Sep 10 2018
%D G. Balzarotti and P. P. Lava, Le sequenze di numeri interi, Hoepli, 2008, p. 160.
%H Harvey P. Dale, <a href="/A119556/b119556.txt">Table of n, a(n) for n = 1..9</a>
%e f(0)=0, f(1) = 0+((-1)^2)*1! = 1, f(2) = 1+((-1)^3)*2! = -1, f(3) = -1+((-1)^4)*3! = 5, which is prime, so 5 is the first term of the sequence.
%p P:=proc(n) local i,j; j:=0; for i from 1 by 1 to n do j:=j+((-1)^(i+1))*i!; if isprime(j) then print(i); fi; od; end: P(100);
%t nxt[{n_,a_}]:={n+1,a+(-1)^(n+1) n!}; Select[NestList[nxt,{1,0},205][[All,2]], #>0 && PrimeQ[#]&] (* _Harvey P. Dale_, Sep 10 2018 *)
%K nonn,easy
%O 1,1
%A _Paolo P. Lava_ and _Giorgio Balzarotti_, May 30 2006
%E Offset changed to 1 (this is a list) by _Bruno Berselli_, Feb 16 2012
%E Definition corrected by _Harvey P. Dale_, Sep 10 2018