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-5 of 5 results.

A333879 a(n) is the number of primes 2^(n-1) <= p < 2^n with maximal Hamming weight A091937(n-1) in this interval.

Original entry on oeis.org

1, 1, 2, 1, 3, 1, 4, 4, 3, 1, 5, 1, 4, 18, 3, 1, 8, 1, 11, 4, 5, 31, 7, 1, 2, 33, 1, 5, 4, 1, 7, 5, 1, 1, 9, 55, 6, 71, 7, 1, 6, 69, 4, 7, 2, 1, 10, 3, 3, 1, 2, 1, 6, 95, 4, 3, 61, 1, 8, 1, 3, 110, 3, 1, 8, 1, 2, 2, 3, 98, 9, 1, 5, 2, 5, 8, 3, 125, 10, 3, 81, 2
Offset: 2

Views

Author

Hugo Pfoertner, Apr 08 2020

Keywords

Crossrefs

Programs

  • Mathematica
    a[2]=1; a[n_] := Block[{c = 0, nb = 0}, While[c == 0, c = Count[2^n - 1 - Total /@ Subsets[2^Range[n - 2], {nb}], x_ /; PrimeQ[x]]; nb++]; c]; a /@ Range[2, 85] (* Giovanni Resta, Apr 09 2020 *)

Extensions

Terms a(35) and beyond from Giovanni Resta, Apr 09 2020

A091938 Smallest prime between 2^n and 2^(n+1), having a maximal number of 1's in binary representation.

Original entry on oeis.org

3, 7, 11, 31, 47, 127, 191, 383, 991, 2039, 3583, 8191, 15359, 20479, 63487, 131071, 245759, 524287, 786431, 1966079, 4128767, 7323647, 14680063, 33546239, 67108351, 100646911, 260046847, 536739839, 1073479679, 2147483647
Offset: 1

Views

Author

Reinhard Zumkeller, Feb 14 2004

Keywords

Comments

A091937(n) = A000120(a(n)).

Crossrefs

Programs

  • Mathematica
    NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; p = 2; Do[c = 0; While[p < 2^n, b = Count[ IntegerDigits[p, 2], 1]; If[c < b, c = b; q = p]; p = NextPrim[p]]; Print[q], {n, 1, 30}] (* Robert G. Wilson v, Feb 21 2004 *)
    b[n_] := Min[ Select[ FromDigits[ #, 2] & /@ (Join[{1}, #, {1}] & /@ Permutations[ Join[{0}, Table[1, {n - 2}]]]), PrimeQ[ # ] &]]; c[n_] := Min[ Select[ FromDigits[ #, 2] & /@ (Join[{1}, #, {1}] & /@ Permutations[ Join[{0, 0}, Table[1, {n - 3}]]]), PrimeQ[ # ] &]]; f[n_] := If[ PrimeQ[2^(n + 1) - 1], 2^(n + 1) - 1, If[ PrimeQ[ b[n]], b[n], c[n]]]; Table[ f[n], {n, 30}] (* Robert G. Wilson v *)
  • Python
    from sympy import isprime
    from sympy.utilities.iterables import multiset_permutations
    def A091938(n):
        for i in range(n,-1,-1):
            q = 2**n
            for d in multiset_permutations('0'*(n-i)+'1'*i):
                p = q+int(''.join(d),2)
                if isprime(p):
                    return p # Chai Wah Wu, Apr 08 2020

Extensions

More terms from Robert G. Wilson v, Feb 20 2004

A091935 Smallest number of 1's in binary representations of primes between 2^n and 2^(n+1).

Original entry on oeis.org

1, 2, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 4, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 4, 3
Offset: 1

Views

Author

Reinhard Zumkeller, Feb 14 2004

Keywords

Comments

a(n) = A000120(A091936(n)).
0 never appears, 1 appears only at 1, 2's appear only for Fermat primes (A019434), 4's appear at A092100. I have found no fives <= 250. - Robert G. Wilson v

Crossrefs

Programs

  • Maple
    f:= proc(n) local i,j,k;
      if isprime(2^n+1) then return 2 fi;
      for i from 1 to n-1 do if isprime(2^n+1+2^i) then return 3 fi od;
      for i from 1 to n-2 do for j from i+1 to n-1 do if isprime(2^n+2^i+2^j+1) then return 4 fi od od;
      error ">=5 found"
    end proc:
    f(1):= 1:
    map(f, [$1..200]); # Robert Israel, Mar 30 2020
  • Mathematica
    Run the second Mathematica line of A091936, then Join[{1}, Count[ IntegerDigits[ #, 2], 1] & /@ Table[ f[n], {n, 2, 105}]] (* Robert G. Wilson v, Feb 19 2004 *)

Extensions

More terms from Robert G. Wilson v, Feb 18 2004

A333877 a(n) is the largest prime 2^(n-1) <= p < 2^n maximizing the Hamming weight of all primes in this interval.

Original entry on oeis.org

3, 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381, 32749, 65519, 131071, 262139, 524287, 1048573, 2097143, 4194301, 8388587, 16777213, 33546239, 67108859, 134217467, 260046847, 536870909, 1073741567, 2147483647, 4294967291, 8589934583, 16911433727
Offset: 2

Views

Author

Hugo Pfoertner, Apr 08 2020

Keywords

Comments

This differs from A014234 at n=1 and then first at n=16: a(16) = 65519 != 65521 = A014234(16). - Alois P. Heinz, Apr 25 2020

Crossrefs

Programs

  • Maple
    a:= proc(n) option remember; local i, p;
          for i from 0 do p:= max(select(isprime, map(l-> add(l[j]*
            2^(j-1), j=1..n), combinat[permute]([1$(n-i),0$i]))));
            if p>0 then break fi
          od; p
        end:
    seq(a(n), n=2..30);  # Alois P. Heinz, Apr 23 2020
  • Mathematica
    a[n_] := a[n] = MaximalBy[{#, DigitCount[#, 2, 1]}& /@ Select[Range[ 2^(n-1), 2^n-1], PrimeQ], Last][[-1, 1]];
    Table[Print[n, " ", a[n]]; a[n], {n, 2, 30}] (* Jean-François Alcover, Nov 09 2020 *)
  • PARI
    for(n=2, 30, my(hmax=0,pmax); forprime(p=2^(n-1), 2^n, my(h=hammingweight(p)); if(h>=hmax,pmax=p;hmax=h)); print1(pmax,", "))
    
  • Python
    from sympy import isprime
    from sympy.utilities.iterables import multiset_permutations
    def A333877(n):
        for i in range(n-1,-1,-1):
            q = 2**n-1
            for d in multiset_permutations('0'*i+'1'*(n-1-i)):
                p = q-int(''.join(d),2)
                if isprime(p):
                    return p # Chai Wah Wu, Apr 08 2020

A092111 a(n) = n+1 minus the greatest number of 1's in the binary representations of primes between 2^n and 2^(n+1).

Original entry on oeis.org

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

Views

Author

Robert G. Wilson v, Feb 20 2004

Keywords

Comments

0's occur only at Mersenne prime exponents (A000043) - 1, twos are in A092112, threes do not appear < 504.
a(n) <= 2 for n <= 2000. - Robert Israel, Mar 05 2020

Crossrefs

Programs

  • Maple
    f:= proc(n) local t,j,k;
      t:= 2^(n+1)-1;
      if isprime(t) then return 0 fi;
      for j from 1 to n-1 do if isprime(t-2^j) then return 1 fi od;
      for j from 1 to n-2 do for k from j+1 to n-1 do
        if isprime(t-2^j-2^k) then return 2 fi od od;
      FAIL
    end proc:
    map(f, [$1..200]); # Robert Israel, Mar 05 2020
  • Mathematica
    Compute the second line of the Mathematica code for A091938, then (Table[n + 1, {n, 105}]) - (Count[ IntegerDigits[ #, 2], 1] & /@ Table[ f[n], {n, 105}])

Formula

a(n) = n+1 - A091937(n).
Showing 1-5 of 5 results.