%I #15 Apr 20 2017 15:11:54
%S 1,2,3,4,5,28,32
%N Integers n such that A138523(n) is 1 or a prime.
%C Inspired by the following triangle for the initial terms:
%C 1! = 1.
%C 1! + 3! = 7.
%C 1! + 3! + 5! = 127.
%C 1! + 3! + 5! + 7! = 5167.
%C 1! + 3! + 5! + 7! + 9! = 368047.
%C This sequence is finite since 107 divides A138523(n) for all n >= 53. - _Amiram Eldar_, Apr 20 2017
%e a(4) = 4 because 1! + 3! + 5! + 7! = 5167 is prime.
%t Select[Range@ 1000, Or[# == 1, PrimeQ@ #] &@ Sum[(2 k - 1)!, {k, #}] &] (* _Michael De Vlieger_, Dec 01 2015 *)
%o (PARI) lista(nn) = { print1(1, ", "); s = 0; for(k=1, nn, s += (2*k-1)!; if(ispseudoprime(s), print1(k, ", ")); ); }
%Y Cf. A008578, A138523.
%K nonn,fini,full
%O 1,2
%A _Altug Alkan_, Dec 01 2015