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

A088781 A068164 indexed by A000040.

Original entry on oeis.org

5, 1, 2, 13, 3, 18, 4, 23, 8, 26, 5, 31, 6, 35, 36, 38, 7, 42, 8, 197, 47, 48, 9, 53, 54, 56, 31, 60, 10, 63, 11, 216, 51, 69, 71, 73, 12, 76, 34, 79, 13, 82, 14, 86, 88, 89, 15, 93, 35, 96, 36, 98, 16, 100, 102, 103, 37, 107, 17, 110, 18, 257, 38, 116, 119, 121, 19, 124, 57, 126
Offset: 1

Views

Author

Ray Chandler, Oct 27 2003

Keywords

Crossrefs

Formula

a(n)=k such that A068164(n)=A000040(k).

A062584 a(n) is the smallest prime whose digits include the digits of n as a substring.

Original entry on oeis.org

101, 11, 2, 3, 41, 5, 61, 7, 83, 19, 101, 11, 127, 13, 149, 151, 163, 17, 181, 19, 1201, 211, 223, 23, 241, 251, 263, 127, 281, 29, 307, 31, 1321, 233, 347, 353, 367, 37, 383, 139, 401, 41, 421, 43, 443, 457, 461, 47, 487, 149, 503, 151, 521, 53, 541, 557, 563
Offset: 0

Views

Author

Jason Earls, Jul 03 2001

Keywords

Comments

a(0) = 101 is the first term where a(n) has two more digits than n. a(665808) = 106658081 is the first term where a(n) has three more digits than n. For which n does a(n) first have four more digits than n? Is lim sup a(n)/n infinite? - Charles R Greathouse IV, Jun 23 2017
Decide how many elements you want to find. Then for every prime, check all substrings to see if they are the first to be in some n. If you've found all values a(n), then you want to stop. - David A. Corneth, Jun 24 2017

Examples

			0 first occurs in 101. 14 first occurs as a substring in 149.
		

Crossrefs

Cf. A082058, A018800, A060386. Similar to but different from A068164. E.g., a(133) = 4133, but A068164(133) = 1033.

Programs

  • Haskell
    import Data.List (isInfixOf)
    a062584 n = head [p | p <- a000040_list, show n `isInfixOf` show p]
    -- Reinhard Zumkeller, Dec 29 2011
    
  • Mathematica
    Do[k = 1; While[ StringPosition[ ToString[Prime[k]], ToString[n]] == {}, k++ ]; Print[ Prime[k]], {n, 0, 62} ]
    (* Second program *)
    Function[s, Table[FromDigits@ FirstCase[s, w_ /; SequenceCount[w, IntegerDigits@ n] > 0], {n, 0, 56}]]@ IntegerDigits@ Prime@ Range[10^4] (* Michael De Vlieger, Jun 24 2017 *)
    With[{prs=Prime[Range[300]]},Table[SelectFirst[prs,SequenceCount[ IntegerDigits[#], IntegerDigits[ n]]>0&],{n,0,60}]] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Dec 06 2018 *)
  • PARI
    build(root, prefixLen, suffixLen)=my(v=List(),t); for(i=10^(prefixLen-1)\1,10^prefixLen-1, t=eval(Str(i,root))*10^suffixLen; for(n=t,t+10^suffixLen-1, listput(v,n))); Vec(v)
    buildLen(n,d)=my(v=[]); for(i=0,d, v=concat(v,build(n,i,d-i))); Set(v)
    a(n)=if(n==0, return(101)); my(d,v); while(1, v=buildLen(n,d); for(i=1,#v, if(isprime(v[i]), return(v[i]))); d++) \\ Charles R Greathouse IV, Jun 23 2017
    
  • PARI
    first(n) = my(res = vector(n), todo = n, g); forprime(p = 2, , d = digits(p); for(i=1,#d, if(d[i]!=0, g = d[i]; if(res[g]==0, res[g]=p; todo--); for(j=1,#d-i, g=10*g+d[i+j]; if(g>n,next(2)); if(res[g]==0, res[g]=p; todo--)))); if(todo==0,return(concat([101],res)))) \\ David A. Corneth, Jun 23 2017
    
  • Python
    from sympy import nextprime
    def a(n):
        p, s = 2, str(n)
        while s not in str(p): p = nextprime(p)
        return p
    print([a(n) for n in range(57)]) # Michael S. Branicky, Dec 02 2021

Formula

a(n) = prime(A082058(n)). - Giovanni Resta, Apr 29 2017

Extensions

More terms from Lior Manor, Jul 08 2001
Corrected by Larry Reeves (larryr(AT)acm.org), Jul 10 2001
Further correction from Reinhard Zumkeller, Oct 14 2001
Name clarified by Jon E. Schoenfield, Dec 04 2021

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

A068165 Smallest square formed from n by inserting zero or more decimal digits.

Original entry on oeis.org

1, 25, 36, 4, 25, 16, 576, 81, 9, 100, 121, 121, 1369, 144, 1156, 16, 1764, 1089, 169, 2025, 121, 225, 2304, 324, 25, 256, 2704, 289, 289, 2304, 361, 324, 3136, 324, 3025, 36, 3721, 3481, 1369, 400, 441, 4225, 4356, 144, 4225, 4096, 4761, 484, 49, 2500
Offset: 1

Views

Author

Amarnath Murthy, Feb 25 2002

Keywords

Comments

The digits may be added before, in the middle of, or after the digits of n.
If n is a square then a(n) = n. - Zak Seidov, Nov 13 2014

Examples

			Smallest square formed from 20 is 2025, by placing 25 on the right side. Smallest square formed from 33 is 3136, by inserting a 1 between 3's and placing a 6.
		

Crossrefs

A091873 gives square roots. Cf. A038690, A029944, A068164.

Programs

  • Maple
    A068165 := proc(n)
            local b,pdigs,plen,dmas,dmasdigs,i,j;
            for b from 1 do
                    pdigs := convert(b^2,base,10) ;
                    plen := nops(pdigs) ;
                    for dmas from 2^plen-1 to 0 by -1 do
                            dmasdigs := convert(dmas,base,2) ;
                            pdel := [] ;
                            for i from 1 to nops(dmasdigs) do
                                    if op(i,dmasdigs) = 1 then
                                            pdel := [op(pdel),op(i,pdigs)] ;
                                    end if;
                            end do:
                            if n = add(op(j,pdel)*10^(j-1),j=1..nops(pdel)) then
                                    return b^2;
                            end if;
                    end do:
            end do:
    end proc:
    seq(A068165(n),n=1..133) ; # R. J. Mathar, Nov 14 2014
  • Python
    from math import isqrt
    from itertools import count
    def dmo(n, t):
        if t < n: return False
        while n and t:
            if n%10 == t%10:
                n //= 10
            t //= 10
        return n == 0
    def a(n):
        return next(t for t in (i*i for i in count(isqrt(n))) if dmo(n, t))
    print([a(n) for n in range(1, 77)]) # Michael S. Branicky, Jan 21 2023

Extensions

Corrected and extended by Ray Chandler, Oct 11 2003

A080470 a(n) = smallest composite number that is obtained by placing digits anywhere in n; a(n) = n if n is composite.

Original entry on oeis.org

10, 12, 30, 4, 15, 6, 27, 8, 9, 10, 110, 12, 123, 14, 15, 16, 117, 18, 119, 20, 21, 22, 123, 24, 25, 26, 27, 28, 129, 30, 231, 32, 33, 34, 35, 36, 237, 38, 39, 40, 141, 42, 143, 44, 45, 46, 147, 48, 49, 50, 51, 52, 153, 54, 55, 56, 57, 58, 159, 60, 161, 62, 63, 64, 65, 66, 267
Offset: 1

Views

Author

Amarnath Murthy, Mar 07 2003

Keywords

Crossrefs

Extensions

Corrected and extended by Ray Chandler, Oct 11 2003

A080471 a(n) is the smallest Fibonacci number that is obtained by placing digits anywhere in n; a(n) = n if n is a Fibonacci number.

Original entry on oeis.org

1, 2, 3, 34, 5, 610, 377, 8, 89, 610, 4181, 121393, 13, 144, 1597, 10946, 1597, 4181, 1597, 832040, 21, 514229, 233, 2584, 2584, 28657, 28657, 2584, 121393, 832040, 317811, 832040, 233, 34, 3524578, 46368, 377, 46368, 121393, 832040, 4181, 514229
Offset: 1

Views

Author

Amarnath Murthy, Mar 07 2003

Keywords

Crossrefs

Programs

  • Maple
    IsSubList:= proc(T, S)
      local i;
      if T = [] then return true fi;
      if S = [] then return false fi;
      i:= ListTools:-Search(T[1],S);
      if i = 0 then false else procname(T[2..-1],S[i+1..-1]) fi
    end proc:
    f:= proc(n) local T,S,k,v;
       T:= convert(n,base,10);
       for k from 1 do
          v:= combinat:-fibonacci(k);
          S:= convert(v,base,10);
          if IsSubList(T,S) then return v fi
       od
    end proc:
    map(f, [$1..100]); # Robert Israel, Mar 10 2020
  • Mathematica
    a[n_] := Block[{p = RegularExpression[ StringJoin @@ Riffle[ ToString /@ IntegerDigits[ n], ".*"]], f, k=2}, While[! StringContainsQ[ ToString[f = Fibonacci[ k++]], p]]; f]; Array[a, 42] (* Giovanni Resta, Mar 10 2020 *)
  • Python
    def dmo(n, t):
        if t < n: return False
        while n and t:
            if n%10 == t%10:
                n //= 10
            t //= 10
        return n == 0
    def fibo(f=1, g=2):
        while True: yield f; f, g = g, f+g
    def a(n):
        return next(f for f in fibo() if dmo(n, f))
    print([a(n) for n in range(1, 77)]) # Michael S. Branicky, Jan 21 2023

Extensions

Corrected and extended by Ray Chandler, Oct 11 2003

A080472 a(n) = smallest triangular number that is obtained by placing digits anywhere in n; a(n) = n if n is a triangular number.

Original entry on oeis.org

1, 21, 3, 45, 15, 6, 78, 28, 91, 10, 171, 120, 136, 1431, 15, 136, 171, 1081, 190, 120, 21, 1225, 231, 2145, 253, 276, 276, 28, 2926, 300, 231, 325, 3003, 2346, 325, 36, 378, 378, 3916, 406, 741, 4278, 435, 4465, 45, 406, 4278, 1485, 496, 1540, 351, 528, 153, 1540
Offset: 1

Views

Author

Amarnath Murthy, Mar 07 2003

Keywords

Crossrefs

Programs

  • Python
    from math import isqrt
    from itertools import count
    def dmo(n, t):
        if t < n: return False
        while n and t:
            if n%10 == t%10:
                n //= 10
            t //= 10
        return n == 0
    def a(n):
        return next(t for t in (i*(i+1)//2 for i in count(isqrt(2*n))) if dmo(n, t))
    print([a(n) for n in range(1, 77)]) # Michael S. Branicky, Jan 21 2023

Extensions

More terms from Ray Chandler, Oct 11 2003

A089754 Smallest prime ending (least significant side) in n if possible else beginning in n.

Original entry on oeis.org

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

Views

Author

Amarnath Murthy, Nov 22 2003

Keywords

Crossrefs

Programs

  • Maple
    read("transforms)"):
    nleadzero := proc(n,dgs)
        local ndgs ;
        if n = 0 then
            ndgs := 0 ;
        else
            ndgs := ilog10(n)+1 ;
        end if;
        [op(convert(n,base,10)),seq(0,i=1..dgs-ndgs)]
    end proc:
    digcatL2 := proc(L1,L2)
        digcatL([op(L1),op(L2)]) ;
    end proc:
    A089754 := proc(n)
        local prep,a,dgs ;
        if isprime(n) then
            n;
        elif modp(n,2) = 0 or modp(n,5) = 0 then
            ndgs := convert(n,base,10) ;
            for dgs from 1 do
                for prep from 0 to 10^dgs-1 do
                    a := digcatL2(ListTools[Reverse](ndgs),ListTools[Reverse](nleadzero(prep,dgs))) ;
                    if isprime(a) then
                        return a;
                    end if;
                end do:
            end do:
        else
            for prep from 1 do
                a := digcat2(prep,n) ;
                if isprime(a) then
                    return a;
                end if;
            end do:
        end if;
    end proc: # R. J. Mathar, Sep 18 2015

Extensions

Corrected by R. J. Mathar, Sep 18 2015

A246398 Smallest number of digits that have to be inserted into or prepended to decimal representation of n, to get a prime.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Nov 13 2014

Keywords

Comments

a(n) = 0 iff n is a prime number, a(A000040(n)) = 0;
a(n) = A055642(A062584(n)) - A055642(n).

Crossrefs

Programs

  • Haskell
    a246398 n = a246398_list !! n
    a246398_list = f 0 $ map show a000040_list where
       f x pss = (length ps - length xs) :
                 f (x + 1) (dropWhile (== xs) pss)
         where ps = head [qs | qs <- pss, isin xs qs]; xs = show x
       isin [] _  = True
       isin _  [] = False
       isin (u:us) vs = not (null ws) && isin us ws
                        where ws = dropWhile (/= u) vs

A385512 a(n) is the least prime p > n in which the digits of n appear as an ordered but not necessarily contiguous subsequence.

Original entry on oeis.org

101, 11, 23, 13, 41, 53, 61, 17, 83, 19, 101, 101, 127, 103, 149, 151, 163, 107, 181, 109, 1201, 211, 223, 223, 241, 251, 263, 127, 281, 229, 307, 131, 1321, 233, 347, 353, 367, 137, 383, 139, 401, 241, 421, 431, 443, 457, 461, 347, 487, 149, 503, 151, 521, 353, 541
Offset: 0

Views

Author

Jean-Marc Rebert, Jul 01 2025

Keywords

Examples

			a(11) = 101, because 101 is the least prime p > 11 in which the digits of 11 appear as an ordered but non-necessarily contiguous subsequence.
		

Crossrefs

Programs

  • Python
    from sympy import sieve
    def osub(n, t): # n > 0 is an ordered_subsequence of t
        if t < n: return False
        while n and t:
            if n%10 == t%10:
                n //= 10
            t //= 10
        return n == 0
    def a(n): return next(p for p in sieve if p > n and osub(n, p)) if n else 101
    print([a(n) for n in range(55)]) # Michael S. Branicky, Jul 01 2025
Showing 1-10 of 10 results.