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.

A018800 Smallest prime that begins with n.

Original entry on oeis.org

11, 2, 3, 41, 5, 61, 7, 83, 97, 101, 11, 127, 13, 149, 151, 163, 17, 181, 19, 2003, 211, 223, 23, 241, 251, 263, 271, 281, 29, 307, 31, 3203, 331, 347, 353, 367, 37, 383, 397, 401, 41, 421, 43, 443, 457, 461, 47, 487, 491, 503, 5101, 521, 53, 541, 557, 563, 571, 587, 59
Offset: 1

Views

Author

Keywords

Comments

Conjecture: If a(n) = (n concatenated with k) then k < n. - Amarnath Murthy, May 01 2002
a(n) always exists. Proof. Suppose n is L digits long, and consider the numbers between n*10^B and n*10^B+10^C, where B > C are both large compared with L. All such numbers begin with the digits of n. Using the upper and lower bounds on pi(x) from Theorem 1 of Rosser and Schoenfeld, it follows that for sufficiently large B and C, at least one of these numbers is a prime. QED - N. J. A. Sloane, Nov 14 2014

Crossrefs

A164022 is the base-2 analog.
Cf. also A258337.
Row n=1 of A262369.

Programs

  • Haskell
    import Data.List (isPrefixOf, find); import Data.Maybe (fromJust)
    a018800 n = read $ fromJust $
                find (show n `isPrefixOf`) $ map show a000040_list :: Int
    -- Reinhard Zumkeller, Jul 01 2015
    
  • Maple
    f:= proc(n) local x0, d,r,y;
       if isprime(n) then return(n) fi;
       for d from 1 do
         x0:= n*10^d;
         for r from 1 to 10^d-1 by 2 do
           if isprime(x0+r) then
              return(x0+r)
           fi
         od
       od
    end proc:
    seq(f(n),n=1..100); # Robert Israel, Dec 23 2014
  • Mathematica
    Table[Function[d, FromDigits@ SelectFirst[ IntegerDigits@ Prime@ Range[10^4], Length@ # >= Length@ d && Take[#, Length@ d] == d &]][ IntegerDigits@ n], {n, 59}] (* Michael De Vlieger, May 24 2016, Version 10 *)
  • PARI
    a(n{,base=10}) = for (l=0, oo, forprime (p=n*base^l, (n+1)*base^l-1, return (p))) \\ Rémy Sigrist, Jun 11 2017
    
  • Python
    from sympy import isprime
    def a(n):
        if isprime(n): return n
        pow10 = 10
        while True:
            t, maxt = n * pow10 + 1, (n+1) * pow10
            while t < maxt:
                if isprime(t): return t
                t += 2
            pow10 *= 10
    print([a(n) for n in range(1, 60)]) # Michael S. Branicky, Nov 02 2021

Formula

a(n) = prime(A085608(n)). - Michel Marcus, Oct 19 2013

A262365 A(n,k) is the n-th prime whose binary expansion begins with the binary expansion of k; square array A(n,k), n>=1, k>=1, read by antidiagonals.

Original entry on oeis.org

2, 2, 3, 3, 5, 5, 17, 7, 11, 7, 5, 19, 13, 17, 11, 13, 11, 37, 29, 19, 13, 7, 53, 23, 67, 31, 23, 17, 17, 29, 97, 41, 71, 53, 37, 19, 19, 67, 31, 101, 43, 73, 59, 41, 23, 41, 37, 71, 59, 103, 47, 79, 61, 43, 29, 11, 43, 73, 131, 61, 107, 83, 131, 97, 47, 31
Offset: 1

Views

Author

Alois P. Heinz, Sep 20 2015

Keywords

Examples

			Square array A(n,k) begins:
:  2,  2,  3,  17,  5,  13,   7,  17, ...
:  3,  5,  7,  19, 11,  53,  29,  67, ...
:  5, 11, 13,  37, 23,  97,  31,  71, ...
:  7, 17, 29,  67, 41, 101,  59, 131, ...
: 11, 19, 31,  71, 43, 103,  61, 137, ...
: 13, 23, 53,  73, 47, 107, 113, 139, ...
: 17, 37, 59,  79, 83, 109, 127, 257, ...
: 19, 41, 61, 131, 89, 193, 227, 263, ...
		

Crossrefs

Columns k=1-7 give: A000040, A080165, A080166, A262286, A262284, A262287, A262285.
Row n=1 gives A164022.
Main diagonal gives A262366.

Programs

  • Maple
    u:= (h, t)-> select(isprime, [seq(h*2^t+k, k=0..2^t-1)]):
    A:= proc(n, k) local l, p;
          l:= proc() [] end; p:= proc() -1 end;
          while nops(l(k))
    				
  • Mathematica
    nmax = 14;
    col[k_] := col[k] = Module[{bk = IntegerDigits[k, 2], lk, pp = {}, coe = 1}, lbk = Length[bk]; While[Length[pp] < nmax, pp = Select[Prime[Range[ coe*nmax]], Quiet@Take[IntegerDigits[#, 2], lbk] == bk&]; coe++]; pp];
    A[n_, k_] := col[k][[n]];
    Table[A[n-k+1, k], {n, 1, nmax}, {k, n, 1, -1}] // Flatten (* Jean-François Alcover, Oct 25 2021 *)

A208241 Smallest prime greater than n, with n as prefix in binary representation.

Original entry on oeis.org

2, 5, 7, 17, 11, 13, 29, 17, 19, 41, 23, 97, 53, 29, 31, 67, 71, 37, 79, 41, 43, 89, 47, 97, 101, 53, 109, 113, 59, 61, 127, 131, 67, 137, 71, 73, 149, 307, 79, 163, 83, 337, 173, 89, 181, 373, 191, 97, 197, 101, 103, 211, 107, 109, 223, 113, 229, 233, 239
Offset: 1

Views

Author

Reinhard Zumkeller, Feb 14 2013

Keywords

Comments

A208238(n) <= a(n);
A174332(n) = a(A000040(n)).

Crossrefs

Cf. A164022 (greater or equal).

Programs

  • Haskell
    import Data.List (genericIndex, find, isPrefixOf)
    import Data.Maybe (fromJust)
    a208241 = genericIndex a208241_list
    a208241_list = f nns $ filter ((== 1) . a010051' . fst) nns where
       f mms'@((m,ms):mms) pps'@((p,ps):pps) =
         if m == p then f mms' pps else q : f mms pps'
         where q = fst $ fromJust $ find ((ms `isPrefixOf`) . snd) pps'
       nns = zip [1..] $ map reverse $ tail a030308_tabf
  • Maple
    A208241 := proc(n)
        local nbin,len,suf,sufbin,pbin,p ;
        nbin := convert(n,base,2) ;
        for len from 1 do
            for suf from 0 to 2^len-1 do
                sufbin := convert(suf,base,2) ;
                while nops(sufbin) < len do
                    sufbin := [op(sufbin),0] ;
                end do:
                pbin := [op(sufbin),op(nbin)] ;
                p := add( 2^(i-1)*op(i,pbin),i=1..nops(pbin) ) ;
                if isprime(p) then
                    return p ;
                end if;
            end do:
        end do:
    end proc:
    seq(A208241(n),n=1..50) ; # R. J. Mathar, May 06 2017

A108234 Minimum m such that n*2^m+k is prime, for k < 2^m. In other words, assuming you've read n out of a binary stream, a(n) is the minimum number of additional bits (appended to the least significant end of n) you must read before it is possible to obtain a prime.

Original entry on oeis.org

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

Views

Author

Mike Stay, Jun 16 2005

Keywords

Comments

Somewhat related to the Riesel problem, A040081, the minimum m such that n*2^m-1 is prime.

Examples

			a(12) = 3 because 12 = 1100 in binary and 97 = 1100001 is the first prime that starts with 1100, needing 3 extra bits.
		

Crossrefs

Cf. A040081, A091991, A164022 (smallest prime).

Programs

  • MATLAB
    % and Octave.
    for n=1:100;m=0;k=0;while(~isprime(n*2^m+k))k=k+1;if k==2^m k=0;m=m+1;end;end;x(n)=m;end;x
    
  • PARI
    A108234(n) = { my(m=0,k=0); while(!isprime((n*2^m)+k), k=k+1; if(2^m==k, k=0; m=m+1)); m; }; \\ Antti Karttunen, Dec 16 2017, after Octave/MATLAB code

Extensions

Definition clarified by Antti Karttunen, Dec 16 2017

A105888 a(n) = the smallest prime that, when written in binary, ends with the substring of 2n-1 in binary.

Original entry on oeis.org

3, 3, 5, 7, 41, 11, 13, 31, 17, 19, 53, 23, 89, 59, 29, 31, 97, 163, 37, 103, 41, 43, 109, 47, 113, 179, 53, 311, 313, 59, 61, 127, 193, 67, 197, 71, 73, 331, 461, 79, 337, 83, 853, 599, 89, 347, 349, 223, 97, 227, 101, 103, 233, 107, 109, 239, 113, 499, 373, 503, 761
Offset: 1

Views

Author

Leroy Quet, Aug 08 2009

Keywords

Examples

			2*5-1 = 9 is 1001 in binary. Looking at the binary numbers that end with 1001: 1001 = 9 in decimal is composite; 11001 = 25 in decimal is composite. But 101001 = 41 in decimal is prime. So a(5) = 41. - Corrected by _Rémy Sigrist_, Feb 05 2020
		

Crossrefs

Cf. A164022.

Programs

  • Maple
    isA105888 := proc(p,n) local pdgs,n21dgs ; pdgs := convert(p,base,2) ; n21dgs := convert(2*n-1,base,2) ; if nops(n21dgs) > nops(pdgs) then return false; else verify( [op(1..nops(n21dgs),n21dgs)],[op(1..nops(n21dgs),pdgs)],'sublist') ; end if; end proc: A105888 := proc(n) p := 2 ; while not isA105888(p,n) do p := nextprime(p) ; end do ; p ; end proc: seq(A105888(n),n=1..80) ; # R. J. Mathar, Dec 06 2009
  • Mathematica
    pr=-16; Select[Prime[Range[200]], MultiplicativeOrder[pr, # ] == #-1 &]
  • PARI
    a(n) = my (m=2*n-1); forstep (p=m, oo, 2^#binary(m), if (isprime(p), return (p)))

Extensions

Extended beyond a(10) by R. J. Mathar, Dec 06 2009
Showing 1-5 of 5 results.