cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A357680 a(n) is the number of primes that can be written as +-1! +- 2! +- 3! +- ... +- n!.

This page as a plain text file.
%I A357680 #49 Nov 22 2022 23:07:36
%S A357680 0,1,3,4,7,11,16,29,42,72,121,191,367,693,1215,2221,4116,7577,13900,
%T A357680 25634,48322,90046,169016,317819,600982,1138049,2158939,4103414,
%U A357680 7818761,14923641,28534404,54624906,104786140,201233500,386914300,744876280,1435592207
%N A357680 a(n) is the number of primes that can be written as +-1! +- 2! +- 3! +- ... +- n!.
%e A357680 For n=4, a(4)=4 means there exist 4 solutions ([17, 19, 29, 31]) as follows:
%e A357680   17 =  1! - 2! - 3! + 4!;
%e A357680   19 = -1! + 2! - 3! + 4!;
%e A357680   29 =  1! - 2! + 3! + 4!;
%e A357680   31 = -1! + 2! + 3! + 4!.
%o A357680 (Python)
%o A357680 from sympy import isprime,factorial
%o A357680 def A357680(nmax):
%o A357680     a=[0]
%o A357680     t=[1]
%o A357680     for n in range(2, nmax+1):
%o A357680         k=factorial(n)
%o A357680         s=[]
%o A357680         for j in t:
%o A357680             s.append(k-j)
%o A357680             s.append(k+j)
%o A357680         a.append(sum(1 for p in s if isprime(p)))
%o A357680         t=s
%o A357680     return(a)
%o A357680 print(A357680(21))
%o A357680 (Python)
%o A357680 from sympy import isprime
%o A357680 from math import factorial
%o A357680 from itertools import product
%o A357680 def a(n):
%o A357680     f = [2*factorial(i) for i in range(1, n+1)]
%o A357680     t = sum(f)//2
%o A357680     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])))
%o A357680 print([a(n) for n in range(1, 20)]) # _Michael S. Branicky_, Oct 15 2022
%Y A357680 Cf. A000142, A059590, A089359.
%K A357680 nonn
%O A357680 1,3
%A A357680 _Zhining Yang_, Oct 09 2022
%E A357680 a(28)-a(30) from _Michael S. Branicky_, Oct 09 2022
%E A357680 a(31)-a(32) from _Michael S. Branicky_, Oct 10 2022
%E A357680 a(33)-a(34) from _Michael S. Branicky_, Oct 13 2022
%E A357680 a(35)-a(36) from _Michael S. Branicky_, Oct 26 2022
%E A357680 a(37) from _Michael S. Branicky_, Nov 13 2022