OFFSET
1,3
EXAMPLE
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!.
PROG
(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
CROSSREFS
KEYWORD
nonn
AUTHOR
Zhining Yang, Oct 09 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
STATUS
approved