A226743 Number of alternating sums of consecutive primes with result 2n-1.
1, 1, 2, 2, 3, 1, 2, 3, 2, 3, 5, 4, 4, 4, 5, 4, 5, 5, 4, 6, 5, 4, 9, 5, 5, 7, 6, 6, 10, 7, 9, 5, 11, 6, 6, 9, 8, 8, 9, 9, 9, 12, 8, 8, 10, 7, 9, 9, 12, 11, 8, 11, 12, 6, 10, 6, 8, 14, 10, 12, 13, 10, 11, 5, 11, 9, 11, 16, 11, 11, 14, 10, 10, 13, 10, 17, 12, 11, 18, 13, 13, 11, 18, 11, 13, 12, 14, 16, 17, 14, 10, 15, 11, 12
Offset: 1
Keywords
Examples
n=5: 11-7+5=2*5-1, 13-11+7=2*5-1, 19-17+13-11+7-5+3=2*5-1, so a(5)=3.
Links
- Robert Israel, Table of n, a(n) for n = 1..10000
Crossrefs
Cf. A084143.
Programs
-
Maple
N:= 100: M:= 2*N-1: # for a(1)..a(N) p:= 1: b:= 0: B:= NULL: for i from 1 do p:= nextprime(p); b:= b + (-1)^i*p; B:= B,b; if b > M then nB:= i; break fi; od: V:= Vector(M): for j from 2 to nB by 2 while B[j] <= M do V[B[j]]:= 1 od: for i from 1 to nB do for j from i+3 to nB by 2 do r:= abs(B[j]-B[i]); if r <= M then V[r]:= V[r]+1 else break fi; od od: seq(V[i],i=1..M,2); # Robert Israel, Feb 06 2025
-
PARI
vb=vecsmall(500);for(k=2,1000,forstep(l=k-1,1,-1,t=sum(i=l,k,prime(i)*(-1)^(k-i));if(t<500,vb[t]=vb[t]+1)))
Comments