A332788 Positive-pan primes (see Comments).
5, 31, 59, 107, 271, 223, 269, 313, 647, 457, 503, 941, 1579, 12919, 3571, 1667, 2897, 3037, 3187, 1993, 3461, 2179, 10141, 5927, 11969, 4957, 13627, 5519, 22787, 3851, 3889, 3929, 15217, 44221, 65867, 21799, 10211, 31727, 24623, 11467, 6983, 7039, 16651, 73351
Offset: 1
Keywords
Examples
2 and 3 unbalance the scale (and go to the negative pan N), but 5 = 2 + 3 balances it (and goes to the positive pan P).
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..10000
Programs
-
Mathematica
a[1]=-2;a[n_]:=a[n]=Module[{tab=Table[a[i],{i,1,n-1}], totalN=Abs[Total[Select[Table[a[i],{i,1,n-1}],Negative]]], totalP=Total[Select[Table[a[i],{i,1,n-1}],Positive]], l=NextPrime[Last[Select[Table[a[i],{i,1,n-1}],Negative]],-1], m=NextPrime[Abs[Last[Select[Table[a[i],{i,1,n-1}],Negative]]]]}, If[totalN==totalP, If[PrimePi[tab[[-1]]]-PrimePi[Abs[tab[[-2]]]]==1,-NextPrime[tab[[-1]]], If[FreeQ[Abs[tab],m],-m,While[! FreeQ[Abs[tab],m],m=NextPrime[m]];-m]], If[PrimeQ[totalN-totalP]&&FreeQ[Abs[tab],totalN-totalP],totalN-totalP, If[FreeQ[Abs[tab],Abs[l]],l,While[!FreeQ[Abs[tab],Abs[l]],l=NextPrime[l,-1]];l] ]]];Select[a/@Range[370],Positive]
-
Python
from itertools import islice from sympy import isprime, nextprime def agen(): # generator of terms used, d, nextp = set(), 0, 2 while True: if d > 0 and d not in used and isprime(d): used.add(d); yield d; d = 0 while nextp in used: nextp = nextprime(nextp) used.add(nextp); d += nextp print(list(islice(agen(), 44))) # Michael S. Branicky, May 12 2022
Extensions
a(41) and beyond from Michael S. Branicky, May 12 2022
Comments