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.

Showing 1-2 of 2 results.

A106701 a(n) = next-to-most-significant binary digit of n-th composite positive integer.

Original entry on oeis.org

0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Offset: 1

Views

Author

Leroy Quet, Jan 22 2006

Keywords

Comments

The length of each run of zeros and ones: 1,3,6,13,25,53,107,219,445,899,1821,... and 1,3,5,12,26,52,106,218,442,894,1811,2838,..., . - Robert G. Wilson v

Examples

			a(2) = 1 because 6 is the second composite and because the next-to-most-significant binary digit (which happens to be the middle binary digit) of 6 = 110 (in binary) is 1.
		

Crossrefs

Programs

  • Mathematica
    f[n_] := IntegerDigits[ FixedPoint[n + PrimePi[ # ] + 1 &, n], 2][[2]]; Array[f, 105] (* Robert G. Wilson v *)

Formula

a(n) = floor((c(n) - 2^m)/2^(m-1)), where c(n) is the n-th composite and m = floor(log(c(n))/log(2)).

Extensions

More terms from Robert G. Wilson v, Jan 24 2006

A175349 a(n) is the smallest positive integer that, when written in binary, contains the binary representations of both the n-th prime and the n-th composite as (possibly overlapping) substrings.

Original entry on oeis.org

4, 6, 40, 39, 43, 108, 113, 79, 368, 466, 500, 149, 361, 344, 377, 53, 59, 988, 542, 2272, 2121, 1103, 2259, 356, 609, 1253, 3304, 3434, 876, 2929, 4078, 387, 393, 2226, 4787, 1687, 630, 2615, 1336, 5561, 2874, 5820, 382, 4033, 12608, 8391, 13506, 14276, 8931, 14662
Offset: 1

Views

Author

Leroy Quet, Apr 19 2010

Keywords

Examples

			The 7th prime is 17, which is 10001 in binary. The 7th composite is 14, which is 1110 in binary. The smallest positive integer that, when written in binary, contains these binary representations as substrings is 113, which is 1110001 in binary. a(7) = 113, therefore.
		

Crossrefs

Programs

  • Maple
    nextcomp:= proc(c)
      if isprime(c+1) then c+2 else c+1 fi
    end proc:
    f:= proc(p,c)
       local Bp, dp, Bc, dc, m, flag1, flag2, x1, x2;
       Bp:= convert(convert(p,binary),string); dp:= length(Bp);
       Bc:= convert(convert(c,binary),string); dc:= length(Bc);
       if dc < dp and StringTools:-Search(Bc, Bp) <> 0 then return p
       elif dp < dc and StringTools:-Search(Bp, Bc) <> 0 then return c
       fi;
       for m from min(dp,dc) to 1 by -1 do
         flag1:= Bp[1..m] = Bc[-m..-1];
         flag2:= Bc[1..m] = Bp[-m..-1];
         if flag1 then x1:= 2^(dp-m) * c + (p mod 2^(dp-m)) fi;
         if flag2 then x2:= 2^(dc-m) * p + (c mod 2^(dc-m)) fi;
         if flag1 and flag2 then return min(x1,x2)
         elif flag1 then return x1
         elif flag2 then return x2
         fi;
       od;
       min(p*2^dc + c, c*2^dp+p)
    end proc:
    p:= 1: c:= 2: R:= NULL:
    for n from 1 to 100 do
      p:= nextprime(p); c:= nextcomp(c);
      R:= R, f(p,c)
    od:
    R; # Robert Israel, Nov 28 2024
  • Mathematica
    comp[n_] := FixedPoint[n + 1 + PrimePi[#] &, n + 1 + PrimePi[n]]; sub[n_, x_] := MemberQ[Partition[IntegerDigits[n, 2], IntegerLength[x, 2], 1],
    IntegerDigits[x, 2]]; a[n_] := Block[{c = comp[n], p = Prime[n], k}, k = Max[p, c]; While[! sub[k,p] || ! sub[k,c], k++]; k]; Array[a, 50] (* Giovanni Resta, Jul 02 2018 *)

Extensions

a(9)-a(50) from Giovanni Resta, Jul 02 2018
Showing 1-2 of 2 results.