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.

A239712 Primes of the form m = 2^i + 2^j - 1, where i > j >= 0.

Original entry on oeis.org

2, 5, 11, 17, 19, 23, 47, 67, 71, 79, 131, 191, 257, 263, 271, 383, 1031, 1039, 1087, 1151, 1279, 2063, 2111, 4099, 4111, 4127, 4159, 5119, 6143, 8447, 16447, 20479, 32771, 32783, 32831, 33023, 33791, 65537, 65539, 65543, 65551, 65599, 66047, 73727, 81919, 262147, 262151, 262271, 262399, 263167
Offset: 1

Views

Author

Hieronymus Fischer, Mar 28 2014 and Apr 22 2014

Keywords

Comments

Numbers m such that b = 2 is the only base such that the base-b digital sum of m + 1 is equal to b.
Example: 5 + 1 = 110_2 which implies ds_2(5 + 1) = 2 = b, where ds_b = digital sum in base-b. However, ds_3(6) = 2 <> 3, ds_4(6) = 3 <> 4, ds_5(6) = 2 <> 5, ds_6(6) = 1 <> 6. For all other bases > 6 we have ds_b(6) = 6 <> b. It follows that b = 2 is the only such base.
The base-2 representation of a term 2^i + 2^j - 1 has a base-2 digital sum of 1 + j.
In base-2 representation the first terms are 10, 101, 1011, 10001, 10011, 10111, 101111, 1000011, 1000111, 1001111, 10000011, 10111111, 100000001, 100000111, 100001111, 101111111, 10000000111, 10000001111, 10000111111, 10001111111, ...
Numbers m = 2^i + 2^j - 1 with odd i and j are not terms. Example: 10239 = 2^13 + 2^11 - 1 is not a prime.

Examples

			a(1) = 2, since 2 = 2^1 + 2^0 - 1 is prime.
a(5) = 19, since 19 = 2^4 + 2^2 - 1 is prime.
		

Crossrefs

Programs

  • Mathematica
    Select[Union[Total/@(2^#&/@Subsets[Range[0,20],{2}])-1],PrimeQ] (* Harvey P. Dale, Aug 08 2014 *)
  • Smalltalk
    A239712
    "Answers the n-th term of A239712.
      Usage: n A239712
      Answer: a(n)"
      | a b i k m p q terms |
      terms := OrderedCollection new.
      b := 2.
      p := 1.
      k := 0.
      m := 0.
      [k < self] whileTrue:
             [m := m + 1.
             p := b * p.
             q := 1.
             i := 0.
             [i < m and: [k < self]] whileTrue:
                       [i := i + 1.
                       a := p + q - 1.
                       a isPrime
                            ifTrue:
                                [k := k + 1.
                                terms add: a].
                       q := b * q]].
      ^terms at: self
    [by Hieronymus Fischer, Apr 22 2014]
    -----------
    
  • Smalltalk
    floorPrimesWhichAreDistinctPowersOf: b withOffset: d
      "Answers an array which holds the primes < n that obey b^i + b^j + d, i>j>=0,
      where n is the receiver. b > 1 (here: b = 2, d = -1).
      Uses floorDistinctPowersOf: from A018900
      Usage:
      n floorPrimesWhichAreDistinctPowersOf: b withOffset: d
      Answer: #(2 5 11 17 19 23 ...) [terms < n]"
      ^((self - d floorDistinctPowersOf: b)
      collect: [:i | i + d]) select: [:i | i isPrime]
    [by Hieronymus Fischer, Apr 22 2014]
    ------------
    
  • Smalltalk
    primesWhichAreDistinctPowersOf: b withOffset: d
      "Answers an array which holds the n primes of the form b^i + b^j + d, i>j>=0, where n is the receiver.
      Direct calculation by scanning b^i + b^j + d in increasing order and selecting terms which are prime.
      b > 1; this sequence: b = 2, d = 1.
      Usage:
      n primesWhichAreDistinctPowersOf: b withOffset: d
      Answer: #(2 5 11 17 19 23 ...) [a(1) ... a(n)]"
      | a k p q terms n |
      terms := OrderedCollection new.
      n := self.
      k := 0.
      p := b.
      [k < n] whileTrue:
             [q := 1.
             [q < p and: [k < n]] whileTrue:
                       [a := p + q + d.
                       a isPrime
                            ifTrue:
                                [k := k + 1.
                                terms add: a].
                       q := b * q].
             p := b * p].
      ^terms asArray
    [by Hieronymus Fischer, Apr 22 2014]

Formula

a(n) = A239708(n) - 1.
a(n+1) = min(A018900(k) > a(n)| A018900(k) - 1 is prime, k >= 1) - 1.

Extensions

Examples moved from Maple field to Examples field by Harvey P. Dale, Aug 08 2014

A239708 Numbers of the form m = 2^i + 2^j, where i > j >= 0, such that m - 1 is prime.

Original entry on oeis.org

3, 6, 12, 18, 20, 24, 48, 68, 72, 80, 132, 192, 258, 264, 272, 384, 1032, 1040, 1088, 1152, 1280, 2064, 2112, 4100, 4112, 4128, 4160, 5120, 6144, 8448, 16448, 20480, 32772, 32784, 32832, 33024, 33792, 65538, 65540, 65544, 65552, 65600, 66048, 73728, 81920, 262148, 262152, 262272, 262400, 263168, 266240, 294912, 524352, 528384, 786432
Offset: 1

Views

Author

Hieronymus Fischer, Mar 27 2014

Keywords

Comments

Complement of the disjunction of A079696 with A187813. This means that a number m is a term if and only if b = 2 is the only base for which the base-b digital sum of m is b.

Examples

			a(1) = 3, since 3 = 2^1 + 2^0.
a(3) = 12, since 12 = 2^3 + 2^2.
		

Crossrefs

Programs

  • Python
    from itertools import islice
    from sympy import isprime
    def A239708_gen(): # generator of terms
        yield (n:=3)
        while True:
            n = n^((a:=-n&n+1)|(a>>1)) if n&1 else ((n&~(b:=n+(a:=n&-n)))>>a.bit_length())^b
            if isprime(n-1):
                yield n
    A239708_list = list(islice(A239708_gen(),30)) # Chai Wah Wu, Mar 24 2025
  • Smalltalk
    A239708
    "Answers the n-th term of A239708.
      Usage: n A239708
      Answer: a(n)"
      | a b i k m p q terms |
      terms := OrderedCollection new.
      b := 2.
      p := 1.
      k := 0.
      m := 0.
      [k < self] whileTrue:
             [m := m + 1.
             p := b * p.
             q := 1.
             i := 0.
             [i < m and: [k < self]] whileTrue:
                       [i := i + 1.
                       a := p + q.
                       (a - 1) isPrime
                            ifTrue:
                                [k := k + 1.
                                terms add: a].
                       q := b * q]].
      ^terms at: self
    -----------------
    
  • Smalltalk
    A239708inv
      "Answers a kind of inverse of A239708.
      Usage: n A239708inv
      Answer: max ( k | A239708(k) < n)"
      | k |
      k := 1.
      [k A239708 < self] whileTrue: [k := k + 1].
      ^k - 1
    

Formula

A239703(a(n)) = 1.

A239709 Primes of the form m = b^i + b^j - 1, where i > j > 0, b > 1.

Original entry on oeis.org

5, 11, 17, 19, 23, 29, 41, 47, 67, 71, 79, 83, 89, 107, 109, 131, 149, 181, 191, 239, 251, 257, 263, 269, 271, 349, 379, 383, 419, 461, 599, 701, 809, 811, 929, 971, 991, 1009, 1031, 1039, 1087, 1151, 1259, 1279, 1301, 1451, 1481, 1511, 1559, 1721, 1871, 1979, 2063, 2069, 2111, 2161, 2213, 2267, 2351, 2549, 2861, 2939, 2969, 3079, 3191, 3389
Offset: 1

Views

Author

Hieronymus Fischer, Mar 27 2014

Keywords

Comments

If m is a term, then there is a base b > 1 such that the base-b representation of m has digital sum = 1 + j*(b-1) == 1 (mod (b-1)).
The base b for which m = b^i + b^j - 1 is not uniquely determined. Example: 11 = 2^3+2^2-1 = 3^2 +3^1-1.
Numbers m which satisfy m = b^i + b^j - 1 with odd i and j and b == 2 (mod 3) are not terms. Example: 12189 = 23^3 + 23^1 - 1 is not a prime.

Examples

			a(1) = 5, since 5 = 2^2 + 2^1 - 1 is prime.
a(2) = 11, since 11 = 2^3 + 2^2 - 1 is prime.
a(6) = 29, since 29 = 3^3 + 3^1 - 1 is prime.
a(10^1) = 71.
a(10^2) = 13109.
a(10^3) = 9336079.
a(10^4) = 2569932329.
a(10^5) = 455578426189.
a(10^6) = 68543190483641.
		

Crossrefs

Programs

  • Smalltalk
    A239709
    "Answers the n-th term of A239709.
      Iterative calculation using A239709_termsLTn.
      Usage: n A239709
      Answer: a(n)"
      | n terms m |
      terms := SortedCollection new.
      n := self.
      m := (n prime // 2) squared.
      terms := m A239709_termsLTn.
      [terms size < n] whileTrue:
             [m := 2 * m.
             terms := m A239709_termsLTn].
      ^terms at: n
      "Remark: A last line of
      ^terms copyFrom: 1 to: n
      answers an array of the first n terms"
    [by_Hieronymus Fischer_, Apr 14 2014]
    -----------
    
  • Smalltalk
    A239709_termsLTn
      "Answers all the terms of A239709 which are < n.
      Direct processing by scanning the scanning the bases b in increasing order, up to b = sqrt(n), and calculating the numbers b^i + b^j - 1.
      Usage: n A239709_termsLTn
      Answer: #(5 11 17 19 23 ...) [terms < n]"
      | bmax p q n m terms a |
      terms := OrderedCollection new.
      n := self.
      bmax := n sqrtTruncated.
      2 to: bmax
         do:
             [:b |
             m := 1 + (n floorLog: b).
             p := b.
             2 to: m
                  by: 1
                  do:
                       [:i |
                       p := b * p.
                       q := b.
                       1 to: i - 1
                            by: 1
                            do:
                                [:j |
                                a := p + q - 1.
                                a < n ifTrue: [a isPrime ifTrue: [terms add: a]].
                                q := b * q]]].
      ^terms asSet asArray sorted
    [by_Hieronymus Fischer_, Apr 14 2014]
    -----------
    
  • Smalltalk
    A239709nTerms
      "Alternative version: Answers the first n terms of A239709. Direct calculation by scanning the numbers b^i + b^j - 1 in increasing order.
      Usage: n A239709
      Answer: a(n)"
      | a amax an b bmax k terms p q p_i q_j a_b amin bamin |
      terms := SortedCollection new.
      p_i := OrderedCollection new.
      q_j := OrderedCollection new.
      a_b := OrderedCollection new.
      p_i add: 1.
      q_j add: 1.
      a_b add: 1.
      k := 0.
      b := 2.
      bmax := b.
      p := b * b.
      q := b.
      a := p + q - 1.
      p_i add: p.
      q_j add: q.
      a_b add: a.
      amax := 2 * (b + 1) + a.
      an := 0.
      [(k < self and: [a < amax]) or: [a < an]] whileTrue:
             [[(k < self and: [a < amax]) or: [a < an]] whileTrue:
                       [[q < p and: [(k < self and: [a < amax]) or: [a < an]]] whileTrue:
                                [a isPrime2
                                     ifTrue:
                                          [(terms includes: a)
                                              ifFalse:
                                                   [k := k + 1.
                                                   terms add: a.
                                                   k >= self ifTrue: [an := terms at: self]]].
                                q := b * q.
                                a := p + q - 1].
                       p = q
                            ifTrue:
                                [p := b * p.
                                q := b.
                                a := p + q - 1].
                       p_i at: b put: p.
                       q_j at: b put: q.
                       a_b at: b put: a].
             amin := a.
             2 to: b - 1
                  do:
                       [:bb |
                       (a_b at: bb) < amin
                            ifTrue:
                                [amin := a_b at: bb.
                                bamin := bb]].
             b + 1 to: bmax
                  do:
                       [:bb |
                       (a_b at: bb) < amin
                            ifTrue:
                                [amin := a_b at: bb.
                                bamin := bb]].
             amin < (a min: amax)
                  ifTrue:
                       [b := bamin.
                       p := p_i at: b.
                       q := q_j at: b.
                       a := a_b at: b]
                  ifFalse:
                       [bmax := bmax + 1.
                       b := bmax.
                       p := b * b.
                       q := b.
                       a := p + q - 1.
                       p_i add: p.
                       q_j add: q.
                       a_b add: a.
                       amax := 2 * (b + 1) + a max: amax]].
      ^terms copyFrom: 1 to: self
    [by_Hieronymus Fischer_, Apr 20 2014]

A239710 Primes of the form m = b^i + b^j + 1, where i > j > 0, b > 1.

Original entry on oeis.org

7, 11, 13, 19, 31, 37, 41, 43, 67, 73, 97, 109, 131, 137, 151, 157, 193, 211, 223, 241, 271, 307, 421, 463, 521, 577, 601, 631, 641, 733, 739, 751, 757, 769, 811, 1033, 1123, 1153, 1303, 1453, 1483, 1723, 1741, 1873, 2053, 2081, 2113, 2269, 2551, 2917, 2971, 3251, 3307, 3391, 3541, 3907, 4099
Offset: 1

Views

Author

Hieronymus Fischer, Mar 27 2014 and May 04 2014

Keywords

Comments

If m is a term, then there is a base b > 1 such that the base-b representation of m has digital sum = 3.
The base b for which m = b^i + b^j + 1 is not uniquely determined. Example: 13 = 2^3+2^2+1 = 3^2 +3^1+1.
Numbers m that satisfy m = b^i + b^j + 1 and b == 1 (mod 3) are not terms.

Examples

			a(1) = 7, since 7 = 2^2 + 2^1 + 1 is prime.
a(2) = 11, since 11 = 2^3 + 2^1 + 1 is prime.
a(5) = 31, since 31 = 3^3 + 3^1 + 1 is prime.
a(10) = 73.
a(100) = 24181.
a(10^3) = 23160157.
a(10^4) = 7039461703.
a(10^5) = 1226630453623.
a(10^6) = 182489744292253.
		

Crossrefs

Programs

  • Smalltalk
    A239710
      "Answers the n-th term of A239710.
    Usage: n A239710
    Answer: a(n)"
      ^(self primesWhichAreDistinctPowersWithOffset: 1) at: self
    -----------
    
  • Smalltalk
    primesWhichAreDistinctPowersWithOffset: d
      "Answers an array which hold the first n primes of the form b^i + b^j + d, i>j>0, where n is the receiver. Iterative calculation, b > 1.
      Usage: n primesWhichAreDistinctPowersWithOffset: d
    Answer: all terms < n"
      | n terms m |
      terms := OrderedCollection new.
      n := self.
      m := n squared * (n integerCeilLog: 2) * 2.
      terms := m primesLTnWhichAreDistinctPowersWithOffset: d.
      [terms size < n] whileTrue:
        [m := 2 * m.
        terms := m primesLTnWhichAreDistinctPowersWithOffset: d].
      ^(terms copyFrom: 1 to: n) asArray
    -----------
    
  • Smalltalk
    primesLTnWhichAreDistinctPowersWithOffset: d
      "Answers an array which hold the primes < n of the form b^i + b^j + d, i>j>0, where n is the receiver, b > 1.
      Uses floorDistinctPowersWithOffset: d from A242100"
      ^(self floorDistinctPowersWithOffset: d) select: [:i | i isPrime]

A239711 Twin primes of the form m = b^i + b^j +- 1, where i > j > 0, b > 1.

Original entry on oeis.org

5, 7, 11, 13, 17, 19, 29, 31, 41, 43, 71, 73, 107, 109, 149, 151, 191, 193, 239, 241, 269, 271, 419, 421, 461, 463, 599, 601, 809, 811, 1031, 1033, 1151, 1153, 1301, 1303, 1451, 1453, 1481, 1483, 1721, 1723, 1871, 1873, 2111, 2113, 2267, 2269, 2549, 2551, 2969, 2971, 3389, 3391, 3539, 3541
Offset: 1

Views

Author

Hieronymus Fischer, Mar 27 2014 and May 04 2014

Keywords

Comments

(a(2k-1), a(2k)), k > 0, form pairs of twin primes.
Numbers m that satisfy m = b^i + b^j + 1 and b == 1 (mod 3) and those that satisfy m = b^i + b^j - 1 with odd i and j and b == 2 (mod 3) are never terms, since they are divisible by 3. It follows that no numbers 4^i + 4^j +- 1, or 7^i + 7^j +- 1, or 10^i + 10^j +- 1, ... can be terms. Also, no numbers 5^(2m-1) + 5^(2k-1) +- 1, or 8^(2m-1) + 8^(2k-1) +- 1, or 11^(2m-1) + 11^(2k-1) +- 1, ... with m > k > 0, can be terms.
Example 1: 10^6 + 10^4 + 1 = 1010001 is not a term, since 10 == 1 (mod 3); certainly, 1010001 = 3*336667.
Example 2: 8^9 + 8^7 - 1 = 136314879 is not a term, since 8 == 2 (mod 3) and i, j odd; certainly 136314879 = 3*45438293.

Examples

			a(1) = 5, since 5 = 2^2 + 2^1 - 1 is prime.
a(2) = 7, since 7 = 2^3 + 2^1 + 1 is prime.
a(7) = 29, since 29 = 3^3 + 3^1 - 1 is prime.
a(8) = 31, since 31 = 3^3 + 3^1 + 1 is prime.
a(9) = 41.
a(10) = 43.
a(99) = 43889.
a(100) = 43891.
a(999) = 233524241.
a(1000) = 233524243.
a(9999) = 110211052379.
a(10000) = 110211052381.
a(99999) = 27208914574871.
a(100000) = 27208914574873.
a(199999) = 136140088764371.
a(200000) = 136140088764373.
[the last two terms form the 100000th twin prime pair of the form b^i + b^j +-1]
		

Crossrefs

A239713 Primes of the form m = 3^i + 3^j - 1, where i > j >= 0.

Original entry on oeis.org

3, 11, 29, 83, 89, 107, 251, 269, 809, 971, 2213, 2267, 6563, 6569, 6803, 8747, 19709, 19763, 20411, 59051, 65609, 177173, 183707, 531521, 538001, 590489, 1594331, 1594403, 1595051, 1596509, 4782971, 4782977, 4783697, 14348909, 14349149, 14526053, 14880347
Offset: 1

Views

Author

Hieronymus Fischer, Mar 28 2014

Keywords

Comments

The base-3 representation of a term 3^i + 3^j - 1 has base-3 digital sum = 1 + 2*j == 1 (mod 2).
In base-3 representation the first terms are 10, 102, 1002, 10002, 10022, 10222, 100022, 100222, 1002222, 1022222, 10000222, 10002222, 100000002, 100000022, 100022222, 102222222, 1000000222, 1000002222, 1000222222, 10000000002, 10022222222, 100000000222, 100022222222, ...

Examples

			a(1) = 3, since 3 = 3^1 + 3^0 - 1 is prime.
a(5) = 89, since 89 = 3^4 + 3^2 - 1 is prime.
		

Crossrefs

Cf. A018900, A239709, A239712 (base 2), A239714 (base 4), A239715 (base 5), A239716 (base 6), A239717 (base 7), A239718 (base 8), A239719 (base 9), A239720 (base 10).

Programs

  • Maple
    select(isprime, [seq(seq(3^i+3^j-1, j=0..i-1), i=1..25)])[];  # Alois P. Heinz, Dec 22 2024
  • Mathematica
    Select[Flatten[Table[3^i + 3^j - 1, {i, 1, 25}, {j, 0, i - 1}]], PrimeQ] (* Jean-François Alcover, Mar 17 2025, after Alois P. Heinz *)
  • Smalltalk
    A239713
    "Answers the n-th term of A239713.
      Usage: n A239713
      Answer: a(n)"
      | a b i j k p q terms |
      terms := OrderedCollection new.
      k := 0.
      b := 3.
      p := b.
      i := 1.
      [k < self] whileTrue:
             [j := 0.
             q := 1.
             [j < i and: [k < self]] whileTrue:
                       [a := p + q - 1.
                       a isPrime
                            ifTrue:
                                [k := k + 1.
                                terms add: a].
                       q := b * q.
                       j := j + 1].
             i := i + 1.
             p := b * p].
         ^terms at: self
    [by Hieronymus Fischer, Apr 14 2014]
    --------------------
    
  • Smalltalk
    A239713
    "Version 2: Answers the n-th term of A239713.
      Uses distinctPowersOf: b from A018900
      Usage: n A239713
      Answer: a(n)”
      | a k n terms |
      terms := OrderedCollection new.
      n := 1.
      k := 0.
      [k < self] whileTrue:
             [(a:= (n distinctPowersOf: 3) - 1)
                  isPrime ifTrue:    [k := k + 1.
                                     terms add: a].
                  n := n + 1].
      ^terms at: self
    [by Hieronymus Fischer, Apr 22 2014]
    -----------
    
  • Smalltalk
    A239713
      "Version 3: Answer an array of the first n terms of A239713.
      Uses method primesWhichAreDistinctPowersOf: b withOffset: d from A239712.
      Usage: n A239713
      Answer: #(3 11 29 ... ) [a(1) ... a(n)]”
      ^self primesWhichAreDistinctPowersOf: 3 withOffset: -1
    [by Hieronymus Fischer, Apr 22 2014]

A239718 Primes of the form m = 8^i + 8^j - 1, where i > j >= 0.

Original entry on oeis.org

71, 4159, 32831, 262151, 266239, 294911, 2101247, 18874367, 134479871, 1073741831, 68721573887, 549755813951, 4398046515199, 4398046543871, 4398046773247, 4398063288319, 281474976711167, 281474976743423, 281474978807807, 281474993487871, 282024732524543
Offset: 1

Views

Author

Hieronymus Fischer, Apr 14 2014

Keywords

Comments

The base-8 representation of a term 8^i + 8^j - 1 has base-8 digital sum = 1 + 7*j == 1 (mod 7).
In base-8 representation the first terms are 107, 10077, 100077, 1000007, 1007777, 1077777, 10007777, 107777777, 1000777777, 10000000007, 1000007777777, 10000000000077, 100000000007777, ...
Numbers m that satisfy m = 8^i + 8^j - 1 with odd i and j are not terms. Example: 33279 = 8^5 + 8^3 - 1 = 3*11093.

Examples

			a(1) = 71, since 71 = 8^2 + 8^1 - 1 is prime.
a(2) = 4159, since 4159 = 8^4 + 8^2 - 1 is prime.
		

Crossrefs

Cf. A018900, A239709, A239712 (base 2), A239713 (base 3), A239714 (base 4), A239715 (base 5), A239716 (base 6), A239717 (base 7), A239719 (base 9), A239720 (base 10).

Programs

  • Maple
    select(isprime, [seq(seq(8^i+8^j-1, j=0..i-1), i=1..25)])[];  # Alois P. Heinz, Dec 22 2024
  • Smalltalk
    A239718
      "Answers an array of the first n terms of A239718.
      Uses method primesWhichAreDistinctPowersOf: b withOffset: d from A239712.
    Usage: n A239718
    Answer: #(71 4159 ... ) [a(1) ... a(n)]"
      ^self primesWhichAreDistinctPowersOf: 8 withOffset: -1
Showing 1-7 of 7 results.