|
|
A357680
|
|
a(n) is the number of primes that can be written as +-1! +- 2! +- 3! +- ... +- n!.
|
|
1
|
|
|
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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,3
|
|
LINKS
|
|
|
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
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)
(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])))
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|