OFFSET
1,1
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.
LINKS
Hieronymus Fischer, Table of n, a(n) for n = 1..250
FORMULA
EXAMPLE
a(1) = 2, since 2 = 2^1 + 2^0 - 1 is prime.
a(5) = 19, since 19 = 2^4 + 2^2 - 1 is prime.
MATHEMATICA
Select[Union[Total/@(2^#&/@Subsets[Range[0, 20], {2}])-1], PrimeQ] (* Harvey P. Dale, Aug 08 2014 *)
PROG
(Smalltalk)
"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]
CROSSREFS
KEYWORD
nonn
AUTHOR
Hieronymus Fischer, Mar 28 2014 and Apr 22 2014
EXTENSIONS
Examples moved from Maple field to Examples field by Harvey P. Dale, Aug 08 2014
STATUS
approved