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

A024770 Right-truncatable primes: every prefix is prime.

Original entry on oeis.org

2, 3, 5, 7, 23, 29, 31, 37, 53, 59, 71, 73, 79, 233, 239, 293, 311, 313, 317, 373, 379, 593, 599, 719, 733, 739, 797, 2333, 2339, 2393, 2399, 2939, 3119, 3137, 3733, 3739, 3793, 3797, 5939, 7193, 7331, 7333, 7393, 23333, 23339, 23399, 23993, 29399, 31193
Offset: 1

Views

Author

Keywords

Comments

Primes in which repeatedly deleting the least significant digit gives a prime at every step until a single-digit prime remains. The sequence ends at a(83) = 73939133 = A023107(10).
The subsequence which consists of the following "chain" of consecutive right truncatable primes: 73939133, 7393913, 739391, 73939, 7393, 739, 73, 7 yields the largest sum, compared with other chains formed from subsets of this sequence: 73939133 + 7393913 + 739391 + 73939 + 7393 + 739 + 73 + 7 = 82154588. - Alexander R. Povolotsky, Jan 22 2008
Can also be seen as a table whose n-th row lists the n-digit terms; row lengths (0 for n >= 9) are given by A050986. The sequence can be constructed starting with the single-digit primes and appending, for each p in the list, the primes within 10*p and 10(p+1), formed by appending a digit to p. - M. F. Hasler, Nov 07 2018

References

  • Roozbeh Hazrat, Mathematica: A Problem-Centered Approach, Springer London 2010, pp. 86-89.
  • James J. Tattersall, Elementary Number Theory in Nine Chapters, Cambridge University Press, 1999, pages 112-113.

Crossrefs

Supersequence of A085823, A202263. Subsequence of A012883, A068669. - Jaroslav Krizek, Jan 28 2012
Supersequence of A239747.
Cf. A033664, A024785 (left-truncatable primes), A032437, A020994, A052023, A052024, A052025, A050986, A050987, A069866, A077390 (left-and-right-truncatable primes), A137812 (left-or-right truncatable primes), A254751, A254753.
Cf. A237600 for the base-16 analog.

Programs

  • Haskell
    import Data.List (inits)
    a024770 n = a024770_list !! (n-1)
    a024770_list = filter (\x ->
       all (== 1) $ map (a010051 . read) $ tail $ inits $ show x) a038618_list
    -- Reinhard Zumkeller, Nov 01 2011
    
  • Maple
    s:=[1,3,7,9]: a:=[[2],[3],[5],[7]]: l1:=1: l2:=4: do for j from l1 to l2 do for k from 1 to 4 do d:=[s[k],op(a[j])]: if(isprime(op(convert(d, base, 10, 10^nops(d)))))then a:=[op(a), d]: fi: od: od: l1:=l2+1: l2:=nops(a): if(l1>l2)then break: fi: od: seq(op(convert(a[j], base, 10, 10^nops(a[j]))),j=1..nops(a)); # Nathaniel Johnston, Jun 21 2011
  • Mathematica
    max = 100000; truncate[p_] := If[PrimeQ[q = Quotient[p, 10]], q, p]; ok[p_] := FixedPoint[ truncate, p] < 10; p = 1; A024770 = {}; While[ (p = NextPrime[p]) < max, If[ok[p], AppendTo[ A024770, p]]]; A024770 (* Jean-François Alcover, Nov 09 2011, after Pari *)
    eppQ[n_]:=AllTrue[FromDigits/@Table[Take[IntegerDigits[n],i],{i, IntegerLength[ n]-1}], PrimeQ]; Select[Prime[Range[3400]],eppQ] (* The program uses the AllTrue function from Mathematica version 10 *) (* Harvey P. Dale, Jan 14 2015 *)
  • PARI
    {fileO="b024770.txt";v=vector(100);v[1]=2;v[2]=3;v[3]=5;v[4]=7;j=4;j1=1; write(fileO,"1 2");write(fileO,"2 3");write(fileO,"3 5");write(fileO,"4 7"); until(0,if(j1>j,break);new=1;for(i=j1,j,if(new,j1=j+1;new=0);for(k=1,9, z=10*v[i]+k;if(isprime(z),j++;v[j]=z;write(fileO,j," ",z);))));} \\ Harry J. Smith, Sep 20 2008
    
  • PARI
    for(n=2, 31193, v=n; while(isprime(n), c=n; n=(c-lift(Mod(c, 10)))/10); if(n==0, print1(v, ", ")); n=v); \\ Arkadiusz Wesolowski, Mar 20 2014
    
  • PARI
    A024770=vector(9, n, p=concat(apply(t->primes([t, t+1]*10), if(n>1, p)))) \\ The list of n-digit terms, 1 <= n <= 9. Use concat(%) to "flatten" it. - M. F. Hasler, Nov 07 2018
    
  • Python
    from sympy import primerange
    p = lambda x: list(primerange(x, x+10)); A024770 = p(0); i=0
    while iA024770): A024770+=p(A024770[i]*10); i+=1 # M. F. Hasler, Mar 11 2020

A024785 Left-truncatable primes: every suffix is prime and no digits are zero.

Original entry on oeis.org

2, 3, 5, 7, 13, 17, 23, 37, 43, 47, 53, 67, 73, 83, 97, 113, 137, 167, 173, 197, 223, 283, 313, 317, 337, 347, 353, 367, 373, 383, 397, 443, 467, 523, 547, 613, 617, 643, 647, 653, 673, 683, 743, 773, 797, 823, 853, 883, 937, 947, 953, 967, 983, 997, 1223
Offset: 1

Views

Author

Keywords

Comments

Last term is a(4260) = 357686312646216567629137 (Angell and Godwin). - Eric W. Weisstein, Dec 11 1999
Can be seen as table whose rows list n-digit terms, 1 <= n <= 25. Row lengths are A050987. - M. F. Hasler, Nov 07 2018

References

  • James J. Tattersall, Elementary Number Theory in Nine Chapters, Cambridge University Press, 1999, page 113.

Crossrefs

Supersequence of A240768.
Cf. A033664, A032437, A020994, A024770 (right-truncatable primes), A052023, A052024, A052025, A050986, A050987, A077390 (left-and-right truncatable primes), A137812 (left-or-right truncatable primes), A254753.

Programs

  • Haskell
    import Data.List (tails)
    a024785 n = a024785_list !! (n-1)
    a024785_list = filter (\x ->
       all (== 1) $ map (a010051 . read) $ init $ tails $ show x) a038618_list
    -- Reinhard Zumkeller, Nov 01 2011
    
  • Maple
    a:=[[2],[3],[5],[7]]: l1:=1: l2:=4: for n from 1 to 3 do for k from 1 to 9 do for j from l1 to l2 do d:=[op(a[j]),k]: if(isprime(op(convert(d,base,10,10^nops(d)))))then a:=[op(a), d]: fi: od: od: l1:=l2+1: l2:=nops(a): if(l1>l2)then break: fi: od: seq(op(convert(a[j],base,10,10^nops(a[j]))),j=1..nops(a)); # Nathaniel Johnston, Jun 21 2011
    # second Maple program:
    T:= proc(n) option remember; `if`(n=0, "", sort(select(isprime,
          map(x-> seq(parse(cat(j, x)), j=1..9), [T(n-1)])))[])
        end:
    seq(T(n), n=1..4);  # Alois P. Heinz, Sep 01 2021
  • Mathematica
    max = 2000; truncate[p_] := If[id = IntegerDigits[p]; FreeQ[id, 0] && (Last[id] == 3 || Last[id] == 7) && PrimeQ[q = FromDigits[ Rest[id]]], q, p]; ok[n_] := FixedPoint[ truncate, n] < 10;p = 5; A024785 = {2, 3, 5}; While[(p = NextPrime[p]) < max, If[ok[p], AppendTo[A024785, p]]]; A024785 (* Jean-François Alcover, Nov 09 2011 *)
    d[n_]:=IntegerDigits[n]; ltrQ[n_]:=And@@PrimeQ[NestList[FromDigits[Drop[d[#],1]]&,n,Length[d[n]]-1]]; Select[Range[1225],ltrQ[#]&] (* Jayanta Basu, May 29 2013 *)
    FullList=Sort[Flatten[Table[FixedPointList[Select[Flatten[Table[Range[9]*10^Length@IntegerDigits[#[[1]]] + #[[i]], {i, Length[#]}]], PrimeQ] &, {i}], {i, {2, 3, 5, 7}}]]] (* Fabrice Laussy, Nov 10 2019 *)
  • PARI
    v=vector(4260);v[1]=2;v[2]=3;v[3]=5;v[4]=7;i=0;j=4; until(i>=j,i++;p=v[i];P10=10^(1+log(p)\log(10)); for(k=1,9,z=k*P10+p;if(isprime(z),j++;v[j]=z;))); s=vector(4260);s=vecsort(v);for(i=1,j,write("b024785.txt",i," ",s[i]);); \\
    
  • PARI
    is_A024785(n,t=1)={until(t>10*p,isprime(p=n%t*=10)||return);n==p} \\ M. F. Hasler, Apr 17 2014
    
  • PARI
    A024785=vector(25,n,p=vecsort(concat(apply(p->select(isprime, vector(9,i, i*10^(n-1)+p)),if(n>1,p))))); \\ Yields the list of rows (n-digit terms, n = 1..25). Use concat(%) to flatten. There are faster variants using matrices (vectorv(9,i,1)*p+[1..9]~*10^(n-1)*vector(#p,i,1)) and/or predefined vectors, but they are less concise and this takes less than 0.1 sec. - M. F. Hasler, Nov 07 2018
    
  • Python
    from sympy import isprime
    def alst():
      primes, alst = [2, 3, 5, 7], []
      while len(primes) > 0:
        alst += sorted(primes)
        candidates = set(int(d+str(p)) for p in primes for d in "123456789")
        primes = [c for c in candidates if isprime(c)]
      return alst
    print(alst()) # Michael S. Branicky, Apr 11 2021

A020994 Primes that are both left-truncatable and right-truncatable.

Original entry on oeis.org

2, 3, 5, 7, 23, 37, 53, 73, 313, 317, 373, 797, 3137, 3797, 739397
Offset: 1

Views

Author

Mario Velucchi (mathchess(AT)velucchi.it)

Keywords

Comments

Two-sided primes: deleting any number of digits at left or at right, but not both, leaves a prime.
Primes in which every digit string containing the most significant digit or the least significant digit is prime. - Amarnath Murthy, Sep 24 2003
Intersection of A024785 and A024770. - Robert Israel, Mar 23 2015

References

  • David Wells, The Penguin Dictionary of Curious and Interesting Numbers, p. 178 (Rev. ed. 1997).

Crossrefs

Programs

  • Mathematica
    tspQ[n_] := Module[{idn=IntegerDigits[n], l}, l=Length[idn]; Union[PrimeQ/@(FromDigits/@ Join[Table[Take[idn, i], {i, l}], Table[Take[idn, -i], {i, l}]])]=={True}] Select[Prime[Range[PrimePi[740000]]], tspQ]

Extensions

Corrected by David W. Wilson
Additional comments from Harvey P. Dale, Jul 10 2002

A254750 Numbers such that, in base 10, all their proper prefixes and suffixes represent composites.

Original entry on oeis.org

44, 46, 48, 49, 64, 66, 68, 69, 84, 86, 88, 89, 94, 96, 98, 99, 404, 406, 408, 409, 424, 426, 428, 444, 446, 448, 449, 454, 456, 458, 464, 466, 468, 469, 484, 486, 488, 494, 496, 498, 499, 604, 606, 608, 609, 624, 626, 628, 634, 636, 638
Offset: 1

Views

Author

Stanislav Sykora, Feb 15 2015

Keywords

Comments

A proper prefix (or suffix) of a number m is one which is neither void, nor identical to m.
Alternative definition: Slicing the decimal expansion of a(n) in any way into two nonempty parts, each part represents a composite number.
The list is infinite because any string of two or more digits selected from {4,6,8} represents a member.
Each member a(n) starts, as well as ends, with one of the digits {4,6,8,9}.
Every proper prefix of each member a(n) is a member of A202260, and every proper suffix is a member of A254755.
The sequence is a union of A254752 and A254754.

Examples

			6 is not a member because its expansion cannot be sliced in two.
638 is a member because (6, 38, 63, and 8) are all composites.
		

Crossrefs

Programs

  • PARI
    isComposite(n) = (n>2)&&(!isprime(n));
    slicesIntoComposites(n,b=10) = {my(k=b);if(n0,if(!isComposite(n\k)||!isComposite(n%k),return(0););k*=b);return(1);}

A254751 Numbers such that, in base 10, all their proper prefixes and suffixes represent primes.

Original entry on oeis.org

22, 23, 25, 27, 32, 33, 35, 37, 52, 53, 55, 57, 72, 73, 75, 77, 237, 297, 313, 317, 373, 537, 597, 713, 717, 737, 797, 2337, 2397, 2937, 3113, 3137, 3173, 3797, 5937, 5997, 7197, 7337, 7397, 29397, 31373, 37937, 59397, 73313, 739397
Offset: 1

Views

Author

Stanislav Sykora, Feb 15 2015

Keywords

Comments

A proper prefix (or suffix) of a number m is one which is neither void, nor identical to m.
Alternative definition: Slicing the decimal expansion of a(n) in any way into two nonempty parts, each part represents a prime number.
Every proper prefix of each member a(n) is a member of A024770, and every proper suffix is a member of A024785. Since these are finite sequences, a(n) is also finite. It has 45 members, the largest of which is 739397 and happens to be a prime.
The sequence is a union of A254753 and A020994.
A subsequence of A260181. - M. F. Hasler, Sep 16 2016

Examples

			6 is not a member because its expansion cannot be sliced in two.
597 is a member because (5,97,59, and 7) are all primes.
2331 is excluded because 233 is prime, but 1 is not. - _Gordon Hamilton_, Feb 20 2015
		

Crossrefs

Programs

  • Mathematica
    fQ[n_] := (p = {2, 3, 5, 7}; If[ Union@ Join[p, {Mod[n, 10]}] != p, {False}, Block[{idn = IntegerDigits@ n, lng = Floor@ Log10@ n}, Union@ PrimeQ@ Flatten@ Table[{FromDigits[ Take[idn, i]], FromDigits[ Take[idn, -lng + i - 1]]}, {i, lng}] == {True}]]); Select[ Range@1000000, fQ] (* Robert G. Wilson v, Feb 21 2015 *)
    Select[Range[10,750000],AllTrue[Flatten[Table[FromDigits/@TakeDrop[IntegerDigits[#],n],{n,IntegerLength[#]-1}]],PrimeQ]&] (* Harvey P. Dale, Feb 13 2024 *)
  • PARI
    slicesIntoPrimes(n,b=10) = {my(k=b);if(n0,if(!isprime(n\k)||!isprime(n%k),return(0););k*=b;);return(1);}
    
  • Sage
    def breakIntoPrimes(n):
        D=n.digits()
        for i in [1..len(D)-1]:
            if not(is_prime(sum(D[i:][j]*10^j for j in range(len(D[i:])))) and is_prime(sum(D[:i][j]*10^j for j in range(len(D[:i]))))):
                return False
            else:
                continue
        return True
    [n for n in [10..1000] if breakIntoPrimes(n)] # Tom Edgar, Feb 20 2015

A254754 Prime numbers such that, in base 10, all their proper prefixes and suffixes represent composites.

Original entry on oeis.org

89, 409, 449, 499, 809, 4049, 4549, 4649, 4909, 4969, 6299, 6469, 6869, 6899, 6949, 8009, 8039, 8069, 8209, 8609, 8669, 8699, 8849, 9049, 9209, 9649, 9949, 40009, 40099, 40609, 40639, 40699, 40849, 42209, 42649, 44249, 44699, 45949, 46049, 46099
Offset: 1

Views

Author

Stanislav Sykora, Feb 15 2015

Keywords

Comments

A proper prefix (or suffix) of a number m is one which is neither void, nor identical to m.
Alternative definition: Slice the decimal expansion of the prime number a(n) in any way into two nonempty parts; then both parts represent a composite number.
This sequence is a subset of A254750. Each member a(n) must start with one of the digits {4,6,8,9} and end with 9.
Every proper prefix of each member a(n) is a member of A202260, and every proper suffix is a member of A254755.
These numbers are rare and tend to become rarer with increasing n, but the sequence does not seem to terminate (for example, 4*10^28 + 9 is a member).

Examples

			7 is not a member because its expansion cannot be sliced in two.
The prime 4969 is a member because it is a prime and the slices (4, 969, 49, 69, 496, and 9) are all composites.
		

Crossrefs

Programs

  • Mathematica
    Select[Prime[Range[5,5000]],AllTrue[Flatten[Table[FromDigits/@TakeDrop[IntegerDigits[#],n],{n,IntegerLength[ #]-1}]],CompositeQ]&] (* Harvey P. Dale, Sep 22 2024 *)
  • PARI
    isComposite(n) = (n>2)&&(!isprime(n));
    slicesIntoComposites(n,b=10) = {my(k=b);if(n0,if(!isComposite(n\k)||!isComposite(n%k),return(0););k*=b);return(1);}
    isPrimeSlicingIntoComposites(n,b=10) = isprime(n) && slicesIntoComposites(n,b);

A254752 Composite numbers such that, in base 10, all their proper prefixes and suffixes represent composites.

Original entry on oeis.org

44, 46, 48, 49, 64, 66, 68, 69, 84, 86, 88, 94, 96, 98, 99, 404, 406, 408, 424, 426, 428, 444, 446, 448, 454, 456, 458, 464, 466, 468, 469, 484, 486, 488, 494, 496, 498, 604, 606, 608, 609, 624, 626, 628, 634, 636, 638, 639, 644, 646, 648, 649, 654, 656, 658, 664, 666, 668, 669, 684, 686, 688, 694, 696, 698, 699, 804, 806, 808, 814, 816, 818, 824, 826, 828
Offset: 1

Views

Author

Stanislav Sykora, Feb 15 2015

Keywords

Comments

A proper prefix (or suffix) of a number m is one which is neither void, nor identical to m.
Alternative definition: Slicing the decimal expansion of the composite number a(n) in any way into two nonempty parts, each part represents a composite number.
This list is infinite because any string of two or more digits selected from {4,6,8} is a member.
It is a subsequence of A254750 and shares with it these properties: Each member of a(n) must start, as well as end, with one of the digits {4,6,8,9}. Every proper prefix of each member a(n) is a member of A202260, and every proper suffix is a member of A254755.

Examples

			6 is not a member because its expansion cannot be sliced in two.
The composite 469 is a member because it is a composite and the slices (4, 69, 46, and 9) are all composites.
		

Crossrefs

Programs

  • PARI
    isComposite(n) = (n>2)&&(!isprime(n));
    slicesIntoComposites(n,b=10) = {my(k=b);if(n0,if(!isComposite(n\k)||!isComposite(n%k),return(0););k*=b);return(1);}
    isCompositeSlicingIntoComposites(n,b=10) = isComposite(n) && slicesIntoComposites(n,b);
Showing 1-7 of 7 results.