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.

A108421 Smallest number of ones needed to write in binary representation 2*n as sum of two primes.

This page as a plain text file.
%I A108421 #20 Sep 02 2024 21:58:21
%S A108421 2,4,4,4,5,5,5,5,4,4,5,6,5,5,6,4,5,6,5,5,5,5,6,6,6,5,6,5,6,7,7,7,8,5,
%T A108421 5,6,5,5,6,6,5,6,6,5,6,6,7,8,5,5,6,6,6,6,7,5,6,6,7,8,7,7,8,6,7,5,5,6,
%U A108421 5,5,6,6,5,6,6,5,6,7,7,7,6,6,6,6,6,6,7,6,6,7,7,7,8,7,8,6,5,5,6,6,6,6,7,5,6
%N A108421 Smallest number of ones needed to write in binary representation 2*n as sum of two primes.
%C A108421 a(n) = Min{A000120(p)+A000120(q) : p,q prime and p+q=2*n}.
%C A108421 a(n) = A108422(n) - A108423(n).
%C A108421 a(n) >= A000120(n)+1, with equality for n in A241757. - _Robert Israel_, Mar 25 2018
%H A108421 Robert Israel, <a href="/A108421/b108421.txt">Table of n, a(n) for n = 2..10000</a>
%H A108421 <a href="/index/Go#Goldbach">Index entries for sequences related to Goldbach conjecture</a>
%H A108421 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%e A108421 n=15: 2*15=30 and A002375(15)=3 with 30=7+23=11+19=13+17,
%e A108421 13+17 -> 1101+10001 needs a(15)=5 binary ones, whereas
%e A108421 7+23 -> 111+10111 and 11+19 -> 1011+10011 need more.
%p A108421 N:= 200: # to get a(2)..a(N)
%p A108421 Primes:= select(isprime, [seq(i,i=3..2*N-3,2)]):
%p A108421 Ones:= map(t -> convert(convert(t,base,2),`+`), Primes):
%p A108421 V:= Vector(N): V[2]:= 2:
%p A108421 for i from 1 to nops(Primes) do
%p A108421   p:= Primes[i];
%p A108421   for j from 1 to i do
%p A108421     k:= (p+Primes[j])/2;
%p A108421     if k > N then break fi;
%p A108421     t:= Ones[i]+Ones[j];
%p A108421     if V[k] = 0 or t < V[k] then V[k]:= t fi
%p A108421   od
%p A108421 od:
%p A108421 convert(V[2..N],list); # _Robert Israel_, Mar 25 2018
%t A108421 Min[#]&/@(Table[Total[Flatten[IntegerDigits[#,2]]]&/@Select[ IntegerPartitions[ 2*n,{2}],AllTrue[#,PrimeQ]&],{n,2,110}]) (* _Harvey P. Dale_, Jul 27 2020 *)
%Y A108421 Cf. A000120, A004676, A005843, A007088, A108422, A108423, A241757.
%K A108421 nonn,base
%O A108421 2,1
%A A108421 _Reinhard Zumkeller_, Jun 03 2005