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 11 results. Next

A089392 Magnanimous primes: primes with the property that inserting a "+" in any place between two digits yields a sum which is prime.

Original entry on oeis.org

2, 3, 5, 7, 11, 23, 29, 41, 43, 47, 61, 67, 83, 89, 101, 227, 229, 281, 401, 443, 449, 467, 601, 607, 647, 661, 683, 809, 821, 863, 881, 2221, 2267, 2281, 2447, 4001, 4027, 4229, 4463, 4643, 6007, 6067, 6803, 8009, 8221, 8821, 20261, 24407, 26881, 28429, 40427
Offset: 1

Views

Author

Amarnath Murthy, Nov 10 2003

Keywords

Comments

Original definition: Let the digits of n be abcd. Then bcd+a, cd+ab, d+abc, abcd, etc. must all be primes. If n is a k-digit number then it must produce k such primes.
Partition the digits of n into two groups by placing a '+' sign anywhere inside; the result of the expression is prime in every case. Conjecture: sequence is infinite. 11 is the largest term with all odd digits. 2 is the only member with all even digits. Observation: all two-digit primes with the most significant digit even are members.
In contradiction to the above conjecture, it is rather expected that this sequence is finite, cf. the link to C. Rivera's "Puzzle 401", and G. Resta's web page. Concerning the statement about 2 and 11, one can say that all terms except 2, 11 and 101 consist of even digits followed by a final odd digit. - M. F. Hasler, Dec 25 2014
Primes among the magnanimous numbers A252996. - M. F. Hasler, Dec 25 2014

Examples

			2267 is a member which gives primes 2+267 = 269, 22+67 = 89, 226+7 = 233 and 2267 itself.
		

Crossrefs

Programs

  • Maple
    with(combinat): ds:=proc(s) local j: RETURN(add(s[j]*10^(j-1),j=1..nops(s))):end: for d from 1 to 6 do sch:=[seq([1,op(i),d+1],i=[[],seq([j],j=2..d)])]: for n from 10^(d-1) to 10^d-1 do sn:=convert(n,base,10): fl:=0: for s in sch do m:=add(j,j=[seq(ds(sn[s[i]..s[i+1]-1]),i=1..nops(s)-1)]): if not isprime(m) then fl:=1: break fi od: if fl=0 then printf("%d, ",n) fi od od: # C. Ronaldo
  • Mathematica
    mpQ[n_]:=Module[{idn=IntegerDigits[n],len},len=Length[idn];And@@PrimeQ[ Table[ FromDigits[Take[idn,i]]+FromDigits[Take[idn,-(len-i)]],{i,len}]]]; Select[Range[41000],mpQ] (* Harvey P. Dale, Nov 06 2013 *)
  • PARI
    is_A089392(n)={!for(i=1,#Str(n),ispseudoprime([1,1]*(divrem(n,10^i)))||return)} \\ M. F. Hasler, Dec 25 2014
    
  • Python
    from sympy import isprime
    def ok(n):
        if not isprime(n): return False
        s = str(n)
        return all(isprime(int(s[:i])+int(s[i:])) for i in range(1, len(s)))
    print([k for k in range(357) if ok(k)]) # Michael S. Branicky, Oct 14 2024

Extensions

Corrected and extended by C. Ronaldo (aga_new_ac(AT)hotmail.com), Dec 25 2004
Comments edited by Zak Seidov, Jan 29 2013
Edited by M. F. Hasler, Dec 25 2014

A182178 Beginning with 1, smallest positive integer not yet in the sequence such that two adjacent digits of the sequence (also ignoring commas between terms) sum to a prime.

Original entry on oeis.org

1, 2, 3, 4, 7, 6, 5, 8, 9, 20, 21, 11, 12, 14, 16, 50, 23, 25, 29, 41, 43, 47, 49, 83, 85, 61, 65, 67, 411, 111, 112, 30, 32, 34, 38, 52, 56, 58, 92, 94, 70, 74, 76, 114, 98, 302, 116, 120, 202, 121, 123, 89, 203, 205, 207, 412, 125, 211, 129, 212, 141, 143
Offset: 1

Views

Author

Jim Nastos and Eric Angelini, Apr 16 2012

Keywords

Comments

See A219110 for the numbers which do not occur in this sequence. See A219250 for the analog when "sum" is replaced with "absolute difference", and A219248-A219251 for related sequences. - M. F. Hasler, Apr 11 2013

Examples

			20 follows 9 since 9+2 and 2+0 is prime, and no number less than 20 (not already in the sequence) satisfies the stated property.
		

Crossrefs

Programs

  • Mathematica
    a[1] = 1; a[n_] := a[n] = For[id = IntegerDigits[a[n-1]]; k = 1, True, k++, If[FreeQ[Array[a, n-1], k], dd = Join[id, IntegerDigits[k]]; If[And @@ PrimeQ /@ Plus @@@ Transpose[{Most[dd], Rest[dd]}], Return[k]]]]; Array[a, 62] (* Jean-François Alcover, Apr 17 2013 *)
  • PARI
    A182178_vec={(n, a=[1], u=0)->while(#aM. F. Hasler, Apr 11 2013

A219248 Numbers such that the absolute difference of any two adjacent (decimal) digits is prime.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 13, 14, 16, 18, 20, 24, 25, 27, 29, 30, 31, 35, 36, 38, 41, 42, 46, 47, 49, 50, 52, 53, 57, 58, 61, 63, 64, 68, 69, 70, 72, 74, 75, 79, 81, 83, 85, 86, 92, 94, 96, 97, 130, 131, 135, 136, 138, 141, 142, 146, 147, 149, 161, 163, 164
Offset: 1

Views

Author

M. F. Hasler, Apr 12 2013

Keywords

Comments

Numbers which may (and do) occur in A219250 and A219249 (union {0}).
This is to A219250 and A219249 what A182175 is to A182177 and A182178.

Programs

  • Mathematica
    Select[Range[0,200],And@@PrimeQ[Abs[Differences[IntegerDigits[#]]]]&] (* Harvey P. Dale, Jun 06 2014 *)
  • PARI
    is_A219248(n)={!for(i=2,#n=digits(n),isprime(abs(n[i-1]-n[i]))||return)}
    
  • Python
    def ok(n):
        d = list(map(int, str(n)))
        return all(abs(d[i]-d[i-1]) in {2,3,5,7} for i in range(1, len(d)))
    print([k for k in range(164) if ok(k)]) # Michael S. Branicky, Sep 11 2024
    
  • Python
    from itertools import count, islice
    def A219248gen(seed=None): # generator of terms
        nxt = {None:"123456789", "0":"2357", "1":"3468", "2":"04579",
            "3":"01568", "4":"12679", "5":"02378", "6":"13489",
            "7":"02459", "8":"1356", "9":"2467"}
        def bgen(d, seed=None):
            if d == 0: yield tuple(); return
            yield from ((i,)+t for i in nxt[seed] for t in bgen(d-1, seed=i))
        yield 0
        for d in count(1):
            yield from (int("".join(t)) for t in bgen(d, seed=seed))
    print(list(islice(A219248gen(), 65))) # Michael S. Branicky, Sep 11 2024

A219250 Lexicographically earliest sequence of nonnegative integers such that the absolute difference of any two adjacent digits is prime.

Original entry on oeis.org

0, 2, 4, 1, 3, 5, 7, 9, 6, 8, 13, 14, 16, 18, 30, 20, 24, 25, 27, 29, 41, 31, 35, 36, 38, 50, 52, 42, 46, 47, 49, 61, 63, 53, 57, 58, 64, 68, 69, 70, 72, 74, 75, 79, 202, 92, 94, 96, 81, 83, 85, 86, 97, 203, 130, 205, 207, 241, 302, 413, 131, 303, 135, 242, 414, 136, 138, 141, 305, 246, 142, 416, 146, 147, 247, 249
Offset: 1

Views

Author

M. F. Hasler, Apr 11 2013

Keywords

Comments

See A219249 for the version allowing only positive integers, i.e., starting with a(1)=1.
See A219248 (= range of A219250) for the numbers which occur in this sequence, and A219251 for the complement.
A182177 is the analog of this sequence for replacing "absolute difference" by "sum", A182178 is the same analog for A219249; A182175 is the analog of A219248 and A219110 corresponds to A219251.

Programs

  • PARI
    {(n,a=[0],u=0)->while(#a
    				

A182177 Beginning with 0, smallest positive integer not yet in the sequence such that two adjacent digits of the sequence (also ignoring commas between terms) sum to a prime.

Original entry on oeis.org

0, 2, 1, 4, 3, 8, 5, 6, 7, 41, 11, 12, 9, 20, 21, 14, 16, 50, 23, 25, 29, 43, 47, 49, 83, 85, 61, 65, 67, 411, 111, 112, 30, 32, 34, 38, 52, 56, 58, 92, 94, 70, 74, 76, 114, 98, 302, 116, 120, 202, 121, 123, 89, 203, 205, 207, 412, 125, 211, 129, 212, 141, 143, 214, 147, 414, 149, 216, 161, 165, 230, 232, 167, 416, 502, 303, 234, 305, 238, 307, 430, 250, 252, 320, 256, 503, 258, 321, 292, 323, 294, 325, 298, 329, 432, 341, 434, 343, 438, 347, 470, 349
Offset: 1

Views

Author

Jim Nastos and Eric Angelini, Apr 16 2012

Keywords

Comments

A219250 is the analog of this sequence, replacing "sum" by "absolute difference". A219249 is the same analog for A182178. A219248 is the analog of A182175 and A219251 corresponds to A219110 = terms which do not occur in this sequence, i.e., the complement of its range. - M. F. Hasler, Apr 12 2013

Examples

			41 appears after 7 because 7+4 is prime and 4+1 is prime, and no other number less than 41 (not already in the sequence) satisfies this property. Example: 11 does not directly follow 7 since 7+1 is not prime.
		

Crossrefs

Cf. A182175.

Programs

  • PARI
    A182177_vec={(n, a=[0], u=0)->while(#aM. F. Hasler, Apr 11 2013

A219110 Numbers for which at least one sum of two adjacent digits is not prime.

Original entry on oeis.org

10, 13, 15, 17, 18, 19, 22, 24, 26, 27, 28, 31, 33, 35, 36, 37, 39, 40, 42, 44, 45, 46, 48, 51, 53, 54, 55, 57, 59, 60, 62, 63, 64, 66, 68, 69, 71, 72, 73, 75, 77, 78, 79, 80, 81, 82, 84, 86, 87, 88, 90, 91, 93, 95, 96, 97, 99, 100, 101, 102, 103, 104, 105
Offset: 1

Views

Author

M. F. Hasler, Apr 11 2013

Keywords

Comments

Different from A104211 where ("only") the sum of all digits is considered; of course exactly the two-digit terms coincide.
Numbers missing in A182177 and A182178. Otherwise said, complement of the range of A182177 (in the set of nonnegative integers) and of the range of A182178 (in the set of positive integers) and of A182175 in the set of integers > 9.

Examples

			102 is here because 1+0 is not prime (even though 0+2 is).
		

Programs

  • Mathematica
    Select[Range[10, 105], MemberQ[PrimeQ[Total /@ Partition[IntegerDigits[#], 2, 1]], False] &] (* T. D. Noe, Apr 16 2013 *)
  • PARI
    is(n)=for(i=2,#n=digits(n),isprime(n[i-1]+n[i])||return(1))

A221699 Numbers with property that each sum any pair of digits is prime.

Original entry on oeis.org

11, 12, 14, 16, 20, 21, 23, 25, 29, 30, 32, 34, 38, 41, 43, 47, 49, 50, 52, 56, 58, 61, 65, 67, 70, 74, 76, 83, 85, 89, 92, 94, 98, 111, 112, 114, 116, 121, 141, 161, 203, 205, 211, 230, 250, 302, 320, 411, 502, 520, 611, 1111, 1112, 1114, 1116, 1121, 1141, 1161
Offset: 1

Views

Author

Jaroslav Krizek, Jan 22 2013

Keywords

Comments

Supersequence of A091939. Subsequence of A182175.

Examples

			Number 203 is a term because 2+3=5, 2+0=2, 3+0=3 (primes).
		

Crossrefs

Programs

  • Mathematica
    fQ[n_] := Module[{d = IntegerDigits[n]}, Union[PrimeQ[Plus @@@ Union[Subsets[d, {2}]]]] == {True}]; Select[Range[6000], fQ] (* T. D. Noe, Jan 24 2013 *)
    Select[Range[10,1200],AllTrue[Total/@Subsets[IntegerDigits[#],{2}],PrimeQ]&] (* Harvey P. Dale, Jan 31 2024 *)

A219249 Lexicographically earliest sequence of positive integers such that the absolute difference of any two adjacent digits is prime.

Original entry on oeis.org

1, 3, 5, 2, 4, 6, 8, 13, 14, 7, 9, 20, 24, 16, 18, 30, 25, 27, 29, 41, 31, 35, 36, 38, 50, 52, 42, 46, 47, 49, 61, 63, 53, 57, 58, 64, 68, 69, 70, 72, 74, 75, 79, 202, 92, 94, 96, 81, 83, 85, 86, 97, 203, 130, 205, 207, 241, 302, 413, 131, 303, 135, 242, 414, 136, 138, 141, 305, 246, 142, 416, 146, 147, 247, 249, 250
Offset: 1

Views

Author

Eric Angelini and M. F. Hasler, Apr 11 2013

Keywords

Comments

See A219250 for the version allowing nonnegative integers, i.e., starting with a(1)=0.
See A219248 for the numbers which occur in this sequence, and A219251 for the complement.

Crossrefs

Programs

  • PARI
    {A219249(n,a=[1],u=0)=while(#a
    				

A252996 Magnanimous numbers: numbers such that the sum obtained by inserting a "+" anywhere between two digits gives a prime.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 14, 16, 20, 21, 23, 25, 29, 30, 32, 34, 38, 41, 43, 47, 49, 50, 52, 56, 58, 61, 65, 67, 70, 74, 76, 83, 85, 89, 92, 94, 98, 101, 110, 112, 116, 118, 130, 136, 152, 158, 170, 172, 203, 209, 221, 227, 229, 245, 265, 281, 310, 316, 334, 338, 356
Offset: 1

Views

Author

M. F. Hasler, Dec 25 2014

Keywords

Comments

Inclusion of the single-digit terms is conventional: here the property is voidly satisfied since no sum can be constructed by inserting a + sign between two digits, therefore all possible sums are prime. (It is not allowed to prefix a leading zero (e.g., to forbid 4 = 04 = 0+4) since in that case all terms must be prime and one would get A089392.)
All terms different from 20 and not of the form 10^k+1 have the last digit of opposite parity than that of all other digits.
The sequence is marked as "finite", although we do not have a rigorous proof for this, only very strong evidence (numerical and probabilistic). G. Resta has checked that up to 5e16 the only magnanimous numbers with more than 11 digits are 5391391551358 and 97393713331910, the latter being probably the largest element of this sequence. In that case the 10+33+79+104+112+96+71+35+18+6+5+0+1+1 = 571 terms listed in Wilson's b-file are the complete list, which is what the keyword "full" stands for.

Examples

			245 is in the sequence because the numbers 2 + 45 = 47 and 24 + 5 = 29 are both prime. See the first comment for the single-digit terms.
		

Crossrefs

Programs

  • Maple
    filter:= proc(n) local d;
      for d from 1 to ilog10(n)-1 do
        if not isprime(floor(n/10^d)+(n mod 10^d)) then return false fi
      od:
      true
    end proc:
    select(filter, [$0..10^5]); # Robert Israel, Dec 25 2014
  • Mathematica
    fQ[n_] := Block[{idn = IntegerDigits@ n, lng = Floor@ Log10@ n}, Union@ PrimeQ@ Table[ FromDigits[ Take[ idn, i]] + FromDigits[ Take[ idn, -lng + i -1]], {i, lng}] == {True}]; (* or *)
    fQ[n_] := Block[{lng = Floor@ Log10@ n}, Union@ PrimeQ[ Table[ Floor[n/10^k] + Mod[n, 10^k], {k, lng}]] == {True}];
    fQ[2] = fQ[3] = fQ[5] = fQ[7] = True; Select[ Range@ 500, fQ]
    (* Robert G. Wilson v, Dec 26 2014 *)
    mnQ[n_]:=AllTrue[Total/@Table[FromDigits/@TakeDrop[IntegerDigits[n],i],{i,IntegerLength[n]-1}],PrimeQ]; Join[Range[0,9],Select[Range[ 10,400], mnQ]] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, May 26 2017 *)
  • PARI
    is(n)={!for(i=1,#Str(n)-1,ispseudoprime([1,1]*(divrem(n,10^i)))||return)}
    t=0;vector(100,i,until(is(t++),);t)
    
  • Python
    from sympy import isprime
    def ok(n):
        s = str(n)
        return all(isprime(int(s[:i])+int(s[i:])) for i in range(1, len(s)))
    print([k for k in range(357) if ok(k)]) # Michael S. Branicky, Oct 14 2024

A252495 Restricted magnanimous numbers: numbers such that the sum obtained by inserting a "+" anywhere between two digits gives a prime, but no "leading zeros" may appear.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 14, 16, 20, 21, 23, 25, 29, 30, 32, 34, 38, 41, 43, 47, 49, 50, 52, 56, 58, 61, 65, 67, 70, 74, 76, 83, 85, 89, 92, 94, 98, 110, 112, 116, 118, 130, 136, 152, 158, 170, 172, 221, 227, 229, 245, 265, 281, 310, 316, 334, 338, 356
Offset: 1

Views

Author

M. F. Hasler, Dec 28 2014

Keywords

Comments

Inclusion of the single-digit terms is conventional: here the property is vacuously satisfied since no sum can be constructed by inserting a + sign between two digits, therefore all possible sums are prime. (It is not allowed to prefix a leading zero (e.g., to forbid 4 = 04 = 0+4) since in that case all terms must be prime and one would get A089392.)
The restriction on leading zeros means that numbers with digit 0 other than in the last position are excluded, so this sequence equals A252996 with terms in A252480 removed.
Since all primes > 2 are odd, all terms different from 11 and 20 have the last digit of opposite parity to that of all other digits.
As A252996, this sequence is "finite" (without rigorous proof), and up to 5e16 the only terms with more than 11 digits are 5391391551358 and 97393713331910, the latter being probably the largest element of this sequence (due to Giovanni Resta).
(See links for "intellectual ownership": The sequence (without single-digit terms) was suggested by Eric Angelini, a first list of terms computed by Lars Blomberg, then others. Hans Havermann observed that this is a variant of what had been termed "magnanimous numbers" at least 10 years ago by A. Murthy, G. Resta and/or C. Rivera, cf. A089392 and links.)

Examples

			110 is in the sequence since 1+10=11 and 11+0 = 11 are both prime.
101 is not in the sequence because although 10+1 = 11 and 1+01 = 2 are prime, the latter sum is forbidden since 01 has a leading zero.
Number, smallest and largest of the n-digit terms:
| n   #     min    max
| 1  10      0      9
| 2  33      11     98
| 3  69     110     998
| 4  90     1112    9910
| 5  81    11116    99998
| 6  71    111112   999994
| 7  54   1115756   9959374
| 8  25   11771992  95559998
| 9   9  117711170  995955112
|10   4  1777137770 9151995592
|11   4 22226226625 46884486265
|12   0  -
|13   1     5391391551358
|14   1     97393713331910
|15   0  -
		

Crossrefs

Programs

  • PARI
    is(n)=!for(i=1,#Str(n)-1,ispseudoprime([1,1]*(divrem(n,10^i)))||return)&&(n<100||vecmin(digits(n\10)))
    t=0;vector(100,i,until(is(t++),);t)
Showing 1-10 of 11 results. Next