A357680 a(n) is the number of primes that can be written as +-1! +- 2! +- 3! +- ... +- n!.
0, 1, 3, 4, 7, 11, 16, 29, 42, 72, 121, 191, 367, 693, 1215, 2221, 4116, 7577, 13900, 25634, 48322, 90046, 169016, 317819, 600982, 1138049, 2158939, 4103414, 7818761, 14923641, 28534404, 54624906, 104786140, 201233500, 386914300, 744876280, 1435592207
Offset: 1
Keywords
Examples
For n=4, a(4)=4 means there exist 4 solutions ([17, 19, 29, 31]) as follows: 17 = 1! - 2! - 3! + 4!; 19 = -1! + 2! - 3! + 4!; 29 = 1! - 2! + 3! + 4!; 31 = -1! + 2! + 3! + 4!.
Programs
-
Python
from sympy import isprime,factorial def A357680(nmax): a=[0] t=[1] for n in range(2, nmax+1): k=factorial(n) s=[] for j in t: s.append(k-j) s.append(k+j) a.append(sum(1 for p in s if isprime(p))) t=s return(a) print(A357680(21))
-
Python
from sympy import isprime from math import factorial from itertools import product def a(n): f = [2*factorial(i) for i in range(1, n+1)] t = sum(f)//2 return sum(1 for s in product([0, 1], repeat=n-1) if isprime(t-sum(f[i] for i in range(n-1) if s[i]))) print([a(n) for n in range(1, 20)]) # Michael S. Branicky, Oct 15 2022
Extensions
a(28)-a(30) from Michael S. Branicky, Oct 09 2022
a(31)-a(32) from Michael S. Branicky, Oct 10 2022
a(33)-a(34) from Michael S. Branicky, Oct 13 2022
a(35)-a(36) from Michael S. Branicky, Oct 26 2022
a(37) from Michael S. Branicky, Nov 13 2022