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

A008864 a(n) = prime(n) + 1.

Original entry on oeis.org

3, 4, 6, 8, 12, 14, 18, 20, 24, 30, 32, 38, 42, 44, 48, 54, 60, 62, 68, 72, 74, 80, 84, 90, 98, 102, 104, 108, 110, 114, 128, 132, 138, 140, 150, 152, 158, 164, 168, 174, 180, 182, 192, 194, 198, 200, 212, 224, 228, 230, 234, 240, 242, 252, 258, 264, 270, 272, 278, 282, 284
Offset: 1

Views

Author

Keywords

Comments

Sum of divisors of prime(n). - Labos Elemer, May 24 2001
For n > 1, there are a(n) more nonnegative Hurwitz quaternions than nonnegative Lipschitz quaternions, which are counted in A239396 and A239394, respectively. - T. D. Noe, Mar 31 2014
These are the numbers which are in A239708 or in A187813, but excluding the first 3 terms of A187813, i.e., a number m is a term if and only if m is a term > 2 of A187813, or m is the sum of two distinct powers of 2 such that m - 1 is prime. This means that a number m is a term if and only if m is a term > 2 such that there is no base b with a base-b digital sum of b, or b = 2 is the only base for which the base-b digital sum of m is b. a(6) is the only term such that a(n) = A187813(n); for n < 6, we have a(n) > A187813(n), and for n > 6, we have a(n) < A187813(n). - Hieronymus Fischer, Apr 10 2014
Does not contain any number of the format 1 + q + ... + q^e, q prime, e >= 2, i.e., no terms of A060800, A131991, A131992, A131993 etc. [Proof: that requires 1 + p = 1 + q + ... + q^e, or p = q*(1 + ... + q^(e-1)). This is not solvable because the left hand side is prime, the right hand side composite.] - R. J. Mathar, Mar 15 2018
1/a(n) is the asymptotic density of numbers whose prime(n)-adic valuation is odd. - Amiram Eldar, Jan 23 2021

References

  • C. W. Trigg, Problem #1210, Series Formation, J. Rec. Math., 15 (1982), 221-222.

Crossrefs

Column 1 of A341605, column 2 of A286623 and of A328464.
Partial sums of A125266.

Programs

Formula

a(n) = prime(n) + 1 = A000040(n) + 1.
a(n) = A000005(A034785(n)) = A000203(A000040(n)). - Labos Elemer, May 24 2001
a(n) = A084920(n) / A006093(n). - Reinhard Zumkeller, Aug 06 2007
A239703(a(n)) <= 1. - Hieronymus Fischer, Apr 10 2014
From Ilya Gutkovskiy, Jul 30 2016: (Start)
a(n) ~ n*log(n).
Product_{n>=1} (1 + 2/(a(n)*(a(n) - 2))) = 5/2. (End)

A018900 Sums of two distinct powers of 2.

Original entry on oeis.org

3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 33, 34, 36, 40, 48, 65, 66, 68, 72, 80, 96, 129, 130, 132, 136, 144, 160, 192, 257, 258, 260, 264, 272, 288, 320, 384, 513, 514, 516, 520, 528, 544, 576, 640, 768, 1025, 1026, 1028, 1032, 1040, 1056, 1088, 1152, 1280, 1536, 2049, 2050, 2052, 2056, 2064, 2080, 2112, 2176, 2304, 2560, 3072
Offset: 1

Views

Author

Jonn Dalton (jdalton(AT)vnet.ibm.com), Dec 11 1996

Keywords

Comments

Appears to give all k such that 8 is the highest power of 2 dividing A005148(k). - Benoit Cloitre, Jun 22 2002
Seen as a triangle read by rows, T(n,k) = 2^(k-1) + 2^n, 1 <= k <= n, the sum of the n-th row equals A087323(n). - Reinhard Zumkeller, Jun 24 2009
Numbers whose base-2 sum of digits is 2. - Tom Edgar, Aug 31 2013
All odd terms are A000051. - Robert G. Wilson v, Jan 03 2014
A239708 holds the subsequence of terms m such that m - 1 is prime. - Hieronymus Fischer, Apr 20 2014

Examples

			From _Hieronymus Fischer_, Apr 27 2014: (Start)
a(1) = 3, since 3 = 2^1 + 2^0.
a(5) = 10, since 10 = 2^3 + 2^1.
a(10^2) = 16640
a(10^3) = 35184372089344
a(10^4) = 2788273714550169769618891533295908724670464 = 2.788273714550...*10^42
a(10^5) = 3.6341936214780344527466190...*10^134
a(10^6) = 4.5332938264998904048012398...*10^425
a(10^7) = 1.6074616084721302346802429...*10^1346
a(10^8) = 1.4662184497310967196301632...*10^4257
a(10^9) = 2.3037539289782230932863807...*10^13462
a(10^10) = 9.1836811272250798973464436...*10^42571
(End)
		

Crossrefs

Cf. A000079, A014311, A014312, A014313, A023688, A023689, A023690, A023691 (Hamming weight = 1, 3, 4, ..., 9).
Sum of base-b digits equal b: A226636 (b = 3), A226969 (b = 4), A227062 (b = 5), A227080 (b = 6), A227092 (b = 7), A227095 (b = 8), A227238 (b = 9), A052224 (b = 10). - M. F. Hasler, Dec 23 2016

Programs

  • C
    unsigned hakmem175(unsigned x) {
        unsigned s, o, r;
        s = x & -x; r = x + s;
        o = x ^ r;  o = (o >> 2) / s;
        return r | o;
    }
    unsigned A018900(int n) {
        if (n == 1) return 3;
        return hakmem175(A018900(n - 1));
    } // Peter Luschny, Jan 01 2014
    
  • Haskell
    a018900 n = a018900_list !! (n-1)
    a018900_list = elemIndices 2 a073267_list  -- Reinhard Zumkeller, Mar 07 2012
    
  • Maple
    a:= n-> (i-> 2^i+2^(n-1-i*(i-1)/2))(floor((sqrt(8*n-1)+1)/2)):
    seq(a(n), n=1..100);  # Alois P. Heinz, Feb 01 2022
  • Mathematica
    Select[ Range[ 1056 ], (Count[ IntegerDigits[ #, 2 ], 1 ]==2)& ]
    Union[Total/@Subsets[2^Range[0,10],{2}]] (* Harvey P. Dale, Mar 04 2012 *)
  • PARI
    for(m=1,9,for(n=0,m-1,print1(2^m+2^n", "))) \\ Charles R Greathouse IV, Sep 09 2011
    
  • PARI
    is(n)=hammingweight(n)==2 \\ Charles R Greathouse IV, Mar 03 2014
    
  • PARI
    for(n=0,10^5,if(hammingweight(n)==2,print1(n,", "))); \\ Joerg Arndt, Mar 04 2014
    
  • PARI
    a(n)= my(t=sqrtint(n*8)\/2); 2^t + 2^(n-1-t*(t-1)/2); \\ Ruud H.G. van Tol, Nov 30 2024
    
  • Python
    print([n for n in range(1, 3001) if bin(n)[2:].count("1")==2]) # Indranil Ghosh, Jun 03 2017
    
  • Python
    A018900_list = [2**a+2**b for a in range(1,10) for b in range(a)] # Chai Wah Wu, Jan 24 2021
    
  • Python
    from math import isqrt, comb
    def A018900(n): return (1<<(m:=isqrt(n<<3)+1>>1))+(1<<(n-1-comb(m,2))) # Chai Wah Wu, Oct 30 2024
  • Smalltalk
    distinctPowersOf: b
      "Version 1: Answers the n-th number of the form b^i + b^j, i>j>=0, where n is the receiver.
      b > 1 (b = 2, for this sequence).
      Usage: n distinctPowersOf: 2
      Answer: a(n)"
      | n i j |
      n := self.
      i := (8*n - 1) sqrtTruncated + 1 // 2.
      j := n - (i*(i - 1)/2) - 1.
      ^(b raisedToInteger: i) + (b raisedToInteger: j)
    [by Hieronymus Fischer, Apr 20 2014]
    ------------
    
  • Smalltalk
    distinctPowersOf: b
      "Version 2: Answers an array which holds the first n numbers of the form b^i + b^j, i>j>=0, where n is the receiver. b > 1 (b = 2, for this sequence).
      Usage: n distinctPowersOf: 2
      Answer: #(3 5 6 9 10 12 ...) [first n terms]"
      | k p q terms |
      terms := OrderedCollection new.
      k := 0.
      p := b.
      q := 1.
      [k < self] whileTrue:
             [[q < p and: [k < self]] whileTrue:
                       [k := k + 1.
                       terms add: p + q.
                       q := b * q].
             p := b * p.
             q := 1].
      ^terms as Array
    [by Hieronymus Fischer, Apr 20 2014]
    ------------
    
  • Smalltalk
    floorDistinctPowersOf: b
      "Answers an array which holds all the numbers b^i + b^j < n, i>j>=0, where n is the receiver.
      b > 1 (b = 2, for this sequence).
      Usage: n floorDistinctPowersOf: 2
      Answer: #(3 5 6 9 10 12 ...) [all terms < n]"
      | a n p q terms |
      terms := OrderedCollection new.
      n := self.
      p := b.
      q := 1.
      a := p + q.
      [a < n] whileTrue:
             [[q < p and: [a < n]] whileTrue:
                       [terms add: a.
                       q := b * q.
                       a := p + q].
             p := b * p.
             q := 1.
             a := p + q].
      ^terms as Array
    [by Hieronymus Fischer, Apr 20 2014]
    ------------
    
  • Smalltalk
    invertedDistinctPowersOf: b
      "Given a number m which is a distinct power of b, this method answers the index n such that there are uniquely defined i>j>=0 for which b^i + b^j = m, where m is the receiver;  b > 1 (b = 2, for this sequence).
      Usage: m invertedDistinctPowersOf: 2
      Answer: n such that a(n) = m, or, if no such n exists, min (k | a(k) >= m)"
      | n i j k m |
      m := self.
      i := m integerFloorLog: b.
      j := m - (b raisedToInteger: i) integerFloorLog: b.
      n := i * (i - 1) / 2 + 1 + j.
      ^n
    [by Hieronymus Fischer, Apr 20 2014]
    

Formula

a(n) = 2^trinv(n-1) + 2^((n-1)-((trinv(n-1)*(trinv(n-1)-1))/2)), i.e., 2^A002024(n)+2^A002262(n-1). - Antti Karttunen
a(n) = A059268(n-1) + A140513(n-1). A000120(a(n)) = 2. Complement of A161989. A151774(a(n)) = 1. - Reinhard Zumkeller, Jun 24 2009
A073267(a(n)) = 2. - Reinhard Zumkeller, Mar 07 2012
Start with A000051. If n is in sequence, then so is 2n. - Ralf Stephan, Aug 16 2013
a(n) = A057168(a(n-1)) for n>1 and a(1) = 3. - Marc LeBrun, Jan 01 2014
From Hieronymus Fischer, Apr 20 2014: (Start)
Formulas for a general parameter b according to a(n) = b^i + b^j, i>j>=0; b = 2 for this sequence.
a(n) = b^i + b^j, where i = floor((sqrt(8n - 1) + 1)/2), j = n - 1 - i*(i - 1)/2 [for a Smalltalk implementation see Prog section, method distinctPowersOf: b (2 versions)].
a(A000217(n)) = (b + 1)*b^(n-1) = b^n + b^(n-1).
a(A000217(n)+1) = 1 + b^(n+1).
a(n + 1 + floor((sqrt(8n - 1) + 1)/2)) = b*a(n).
a(n + 1 + floor(log_b(a(n)))) = b*a(n).
a(n + 1) = b^2/(b+1) * a(n) + 1, if n is a triangular number (s. A000217).
a(n + 1) = b*a(n) + (1-b)* b^floor((sqrt(8n - 1) + 1)/2), if n is not a triangular number.
The next term can also be calculated without using the index n. Let m be a term and i = floor(log_b(m)), then:
a(n + 1) = b*m + (1-b)* b^i, if floor(log_b(m/(b+1))) + 1 < i,
a(n + 1) = b^2/(b+1) * m + 1, if floor(log_b(m/(b+1))) + 1 = i.
Partial sum:
Sum_{k=1..n} a(k) = ((((b-1)*(j+1)+i-1)*b^(i-j) + b)*b^j - i)/(b-1), where i = floor((sqrt(8*n - 1) + 1)/2), j = n - 1 - i*(i - 1)/2.
Inverse:
For each sequence term m, the index n such that a(n) = m is determined by n := i*(i-1)/2 + j + 1, where i := floor(log_b(m)), j := floor(log_b(m - b^floor(log_b(m)))) [for a Smalltalk implementation see Prog section, method invertedDistinctPowersOf: b].
Inequalities:
a(n) <= (b+1)/b * b^floor(sqrt(2n)+1/2), equality holds for triangular numbers.
a(n) > b^floor(sqrt(2n)+1/2).
a(n) < b^sqrt(2n)*sqrt(b).
a(n) > b^sqrt(2n)/sqrt(b).
Asymptotic behavior:
lim sup a(n)/b^sqrt(2n) = sqrt(b).
lim inf a(n)/b^sqrt(2n) = 1/sqrt(b).
lim sup a(n)/b^(floor(sqrt(2n))) = b.
lim inf a(n)/b^(floor(sqrt(2n))) = 1.
lim sup a(n)/b^(floor(sqrt(2n)+1/2)) = (b+1)/b.
lim inf a(n)/b^(floor(sqrt(2n)+1/2)) = 1.
(End)
Sum_{n>=1} 1/a(n) = A179951. - Amiram Eldar, Oct 06 2020

Extensions

Edited by M. F. Hasler, Dec 23 2016

A187813 Numbers n whose base-b digit sum is not b for all bases b >= 2.

Original entry on oeis.org

0, 1, 2, 4, 8, 14, 30, 32, 38, 42, 44, 54, 60, 62, 74, 84, 90, 98, 102, 104, 108, 110, 114, 128, 138, 140, 150, 152, 158, 164, 168, 174, 180, 182, 194, 198, 200, 212, 224, 228, 230, 234, 240, 242, 252, 270, 278, 282, 284, 294, 308, 312, 314, 318, 332, 338, 348
Offset: 1

Views

Author

Tom Edgar, Aug 30 2013

Keywords

Comments

Except for 1, every number is even.
No number ends in 6.
Numbers neither in A018900 nor in A226636 nor in A226969 nor in A227062 nor in A227080 nor ... . - R. J. Mathar, Sep 02 2013
From Hieronymus Fischer, Mar 27 2014, May 09 2014: (Start)
A079696 and this sequence have no terms in common.
Numbers which satisfy m == 1 (mod j) and m > j^2 for any j > 1 are not terms.
Example 1: m = 10^k, k>1, is not a term since 10^k == 1 (mod 9) and 10^k > 9^2.
Example 2: m = 1 + 3k, k > 3, is not a term, since m > 3(1+3) > 3^2.
This is the complement of the disjunction of A079696 with A239708.
Disregarding the first 3 terms, these are the numbers which are in A008864 but not in A239708. This leads to the following characterization: A number m > 2 is a term, i.e., satisfies digitalSum_b(m) <> b for all b > 1, if and only m is a prime number + 1 and m is not the sum of two distinct powers of 2.
a(6) is the only term such that a(n) = Prime(n) + 1. For n < 6, we have a(n) < Prime(n) + 1, and for n > 6, we have a(n) > Prime(n) + 1.
(End)

Examples

			8 has binary expansion (1,0,0,0) whose digit sum 1 is not 2,
ternary expansion (2,2) whose digit sum 4 is not 3,
quaternary expansion (2,0) whose digit sum 2 is not 4,
5-ary expansion (1,3) whose digit sum 4 is not 5,
6-ary expansion (1,2) whose digit sum 3 is not 6,
7-ary expansion (1,1) whose digit sum 2 is not 7,
8-ary expansion (1,0) whose digit sum 1 is not 8,
and b-ary expansion (8) when b>8 whose digit sum is 8 not b. Therefore, 8 is in the sequence.
3 has binary expansion (1,1) whose digit sum is 2, so 3 is not in the sequence.
From _Hieronymus Fischer_, Apr 10 2014: (Start)
a(10) = 42 (the 13th prime + 1)
a(100) = 618 (the 113th prime + 1)
a(1000) = 8172 (the 1026th prime + 1)
a(10^4) = 105254 (the 10042nd prime + 1)
a(10^5) = 1300464 (the 100056th prime + 1)
a(10^6) = 15486872 (the 1000063th prime + 1)
a(10^7) = 179425944 (the 10000071st prime + 1)
a(10^8) = 2038076324 (the 10^8 +84th prime + 1)
a(10^9) = 22801765334 (the 10^9 +92nd prime + 1)
a(10^10) = 252097803264 (the 10^10 +102nd prime + 1)
[calculation for large numbers processed with Smalltalk method A187813With: estimate; see Prog section]
(End)
		

Crossrefs

Programs

  • Mathematica
    Q@n_:=AllTrue[Table[{b,Plus@@IntegerDigits[n,b]},{b,2,n}],#[[1]]!=#[[2]]&];
    Select[Range[0, 1000], Q] (* Hans Rudolf Widmer, Oct 08 2022 *)
  • Python
    from itertools import count, islice
    from sympy import isprime
    def A187813_gen(startvalue=0): # generator of terms >= startvalue
        yield from filter(lambda n:n<3 or (isprime(n-1) and n.bit_count()!=2), count(max(startvalue,0)))
    A187813_list = list(islice(A187813_gen(startvalue=20),30)) # Chai Wah Wu, Mar 24 2025
  • Sage
    n=1000 #change n for more terms
    S=[]
    for i in [0..n]:
        test=False
        for b in [2..i]:
            if sum(Integer(i).digits(base=b))==b:
                test=True
                break
        if not test:
            S.append(i)
    S
    # From Hieronymus Fischer, Apr 10 2014: (Start)
    
  • Smalltalk
    A187813NextTerm
      "Calculates the next term of A187813 greater than the receiver, i.e., calculates a(n+1) from a(n).
      Usage: a(n) A187813NextTerm
      Answer: a(n+1)
      Version 1: Using numOfBasesWithDigitalSumEQBase from A239703 ==> fast calculation, since only the divisors of  have to tested to be candidates for bases b with base-b digital sum equal to b"
      | an |
      an := self + 1.
      [an numOfBasesWithDigitalSumEQBase > 0]
      whileTrue: [an := an+1].
      ^an
    -----------
    A187813NextTerm
      "Calculates the next term of A187813 greater than the receiver, i.e., calculates a(n+1) from a(n).
      Usage: a(n) A187813NextTerm
      Answer: a(n+1)
      Version 2: Using the equivalence with A008864 and A239708 ==> even much more faster calculation"
      | p q |
      self < 0 ifTrue: [^0].
      self = 0 ifTrue: [^1].
      self = 1 ifTrue: [^2].
      p := (self - 1) nextPrime.
      q := p+1-(2 raisedToInteger: (p+1 integerFloorLog: 2)).
      [q > 0 and: [(2 raisedToInteger: (q integerFloorLog: 2)) - q = 0]] whileTrue: [p := p nextPrime.
                       q := p + 1 - (2 raisedToInteger: (p + 1 integerFloorLog: 2))].
      ^p + 1
    -----------
    A187813
      "Calculates the n-th term of A187813, iteratively.
      Usage: n A187813
      Answer: a(n)"
      | an n |
      n := self.
      n < 3 ifTrue: [^#(0 1) at: n].
      an := 2.
      4 to: n do: [:i |an := an A187813NextTerm].
      ^an
    -----------
    A187813rec
      "Calculates the n-th term of A187813, using the recursive method <A187813With: param>
      Usage: n A187813
      Answer: a(n)"
      self < 3 ifTrue: [^#(0 1) at: self].
      ^self A187813With: self prime
    -----------
    A187813With: estimate
    "Method to calculate the n-th term of A187813 based on the value estimate, recursively. The n-th prime is a adequate estimate. Valid for n > 2.
      Usage: n A187813With: estimate
      Answer: a(n)"
      | x m |
      (x:=((m:= estimate A239708inv)+self-3) prime + 1) = estimate
          ifFalse: [^self A187813With: x].
      (m + 1) A239708 = x
          ifTrue: [^self A187813With: x + 4].
      ^x
    [End]
    

Formula

From Hieronymus Fischer, Mar 27 2014: (Start)
A239703(a(n)) = 0.
a(n+1) = min (p > a(n) | A239703(p) = 0)
[for a Smalltalk implementation see Prog section, method A187813NextTerm version 1].
a(n+1) = 1 + min (p > a(n) | p is prime AND ((q := p+1 - 2^floor(log_2(p+1)) = 0) OR (2^floor(log_2(q)) <> q)))
[for a Smalltalk implementation see Prog section, method A187813NextTerm version 2].
a(n) > Prime(n), for n > 5.
a(n - m) < Prime(n), for n > 1, where m := i*(i-1)/2 + j - 1, i := floor(log_2(Prime(n))), j := floor(log_2(Prime(n) - 2^i)).
a(n - m) < Prime(n), for n > 32, where m := i*(i-1)/2 + j - 16 with i and j above.
a(n) = Prime(n + m - 3) + 1, where m = max ( k | A239708(k) < a(n)), n > 3.
Remark: This identity can be used to calculate a(n) recursively. For a Smalltalk implementation see Prog section, methods A187813rec and A187813With: estimate.
With same conditions: a(n) = A008864(n + m - 3).
a(n - m + 3) = Prime(n) + 1, where m = max ( k | A239708(k) < Prime(n)), n > 3, provided Prime(n) + 1 is not a term of A239708.
(End)

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

A239703 Number of bases b > 1 for which the base-b digital sum of n is b.

Original entry on oeis.org

0, 0, 0, 1, 0, 2, 1, 2, 0, 2, 2, 2, 1, 4, 0, 2, 1, 3, 1, 4, 1, 4, 2, 1, 1, 4, 1, 1, 2, 4, 0, 5, 0, 5, 3, 1, 2, 7, 0, 2, 3, 5, 0, 4, 0, 4, 3, 1, 1, 5, 1, 3, 2, 3, 0, 5, 2, 6, 1, 1, 0, 8, 0, 2, 2, 5, 3, 5, 1, 2, 2, 4, 1, 8, 0, 1, 4, 3, 2, 4, 1, 6, 3, 2, 0, 10, 2
Offset: 0

Views

Author

Hieronymus Fischer, Mar 31 2014

Keywords

Comments

For the definition of the digital sum, see A007953.
For reference, we write digitSum_b(x) for the base-b digital sum of x according to A007953 (with general base b).
The bases counted exclude the special base 1. The base-1 expansion of a natural number is defined as 1=1_1, 2=11_1, 3=111_1 and so on. As a result, the base-1 digital sum of n is n. The inclusion of base b = 1 would lead to a(1) = 1 instead of a(1) = 0. All other terms remain unchanged.
For odd n > 1 and b := (n + 1)/2 we have digitSum_b(n) = b, and thus a(n) >= 1.
The digitSum_b(n) is < b for bases b which satisfy b > floor((n+1)/2), and thus a(n) <= floor((n+1)/2).
If b is a base such that the base-b digital sum of n is b, then b < n and b - 1 is a divisor of n - 1, thus the number of such bases is limited by the number of divisors of n - 1 (see formula section).
If p < n - 1 is a divisor of n - 1 which satisfy p >= sqrt(n - 1), then digitSum_b(n) = b for b := p + 1. This leads to a lower bound for a(n) (see formula section).
If b - 1 is a divisor of n - 1, then b is not necessarily a base such that base-b digital sum of n is b. Example: 1, 2, 3, 4, 6, 8, 12, 16, and 24 are the divisors < 48 of 48, but digitSum_2(49) = 3, digitSum_3(49) = 5, digitSum_5(49) = 9, digitSum_7(49) = 1.
a(b*n) > 0 for all b > 1 which satisfy digitSum_b(n) = b.
Example 1: digitSum_2(3) = 2, hence a(2*3) > 0.
Example 2: digitSum_3(5) = 3, hence a(3*5) > 0.
The first n with a(n) = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ... are n = 3, 5, 17, 13, 31, 57, 37, 61, 81, 85, ... .

Examples

			a(1) = 1, since digitSum_1(1) = 1 and digitSum_b(1) <> b for all b > 1.
a(2) = 0, since digitSum_1(2) = 2 (because of 2 = 11_1), and digitSum_2(2) = 1 (because of 2 = 10_2), and digitSum_b(2) = 2 for all b > 2.
a(3) = 1, since digitSum_1(3) = 3 (because of 3 = 111_1), and digitSum_2(3) = 2 (because of 3 = 11_2), and digitSum_3(3) = 1 (because of 3 = 10_3), and digitSum_b(3) = 3 for all b > 3.
a(5) = 2, since digitSum_1(5) = 5 (because of 5 = 11111_1), and digitSum_2(5) = 2 (because of 5 = 101_2), and digitSum_3(5) = 3 (because of 5 = 12_3), and digitSum_4(5) = 2 (because of 5 = 11_4), and digitSum_5(5) = 1 (because of 5 = 10_5), and digitSum_b(5) = 5 for all b > 5.
		

Crossrefs

Cf. A000040; A000005 (definition of sigma_0(n)).

Programs

  • Smalltalk
    "> Version 1: simple calculation for small numbers.
      Answer the number of bases b such that the digital sum of n in base b is b.
      Valid for bases b >= 1, thus returning a(1) = 1.
      Using digitalSum from A007953.
      Usage: n numOfBasesWithAltDigitalSumEQBase
      Answer: a(n)"
    numOfBasesWithDigitalSumEQBase
      | numBases b bmax |
      numBases := 0.
      bmax := self + 1 // 2.
      b := 0.
      [b < bmax] whileTrue: [
         b := b + 1
         (self digitalSum: b) = b
         ifTrue: [numBases := numBases + 1]].
      ^numBases
    -----------
    "> Version 2: accelerated calculation for large numbers.
      Answer the number of bases b such that the digital sum of n in base b is b.
      Valid for bases b > 1, thus returning a(1) = 0.
      Using digitalSum from A007953.
      Usage: n numOfBasesWithAltDigitalSumEQBase
      Answer: a(n)"
    numOfBasesWithDigitalSumEQBase
      | numBases div b bsize |
      self < 3 ifTrue: [^0].
      div := (self - 1) divisors.
      numBases := 0.
      bsize := div size - 1.
      1 to: bsize do: [ :i | b := (div at: i) + 1.
       (self digitalSum: b) = b
           ifTrue: [numBases := numBases + 1] ].
      ^numBases

Formula

a(n) = 0, if and only if n is a term of A187813.
a(A187813(n)) = 0.
a(A239708(n)) = 1, for n > 0.
a(A018900(n)) > 0, for n > 0.
a(A079696(n)) > 0, for n > 0.
a(A008864(n)) <= 1, for n > 0.
a(n) <= 1, if n - 1 is a prime.
a(n) <= sigma_0(n - 1) - 1, for n > 1.
a(n) >= floor((sigma_0(n-1)-1)/2), for 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]

A079696 Numbers one more than composite numbers.

Original entry on oeis.org

5, 7, 9, 10, 11, 13, 15, 16, 17, 19, 21, 22, 23, 25, 26, 27, 28, 29, 31, 33, 34, 35, 36, 37, 39, 40, 41, 43, 45, 46, 47, 49, 50, 51, 52, 53, 55, 56, 57, 58, 59, 61, 63, 64, 65, 66, 67, 69, 70, 71, 73, 75, 76, 77, 78, 79, 81, 82, 83, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 96
Offset: 1

Views

Author

Vladeta Jovovic, Jan 31 2003

Keywords

Comments

From Hieronymus Fischer, Mar 27 2014: (Start)
Numbers m such that m == 1 mod j and m > j^2 for any j > 1.
Example: m == 6 mod 10 is a term for m > 6, since m = 6 + 10k = 1 + (2k+1)*5, and m > (2k+1)^2 (for k := 1, m = 16), and m > 5^2 (for k > 1, m > 16).
A187813 and this sequence have no terms in common; this means that for each term a(n) there exists a base b such that the base-b digit sum is b.
Example: m = 1 + 3k, k > 3, is a term, since m > 3(1+3) > 3^2, thus the base-b-digit sum of (m) is = b for any b > 1 (here the base b is k+1 since 1+3k = 2(k+1) + k-1).
In general: Given a term a(n) there are p and q with p >= q > 1 such that a(n) = 1 + p*q. With b := p + 1 we get a(n) = (q-1)*b + b - (q-1), where 1 <= q-1 < b, which implies that the base-b digital sum of a(n) is = q-1 + b - (q-1) = b.
This sequence is the complement of the disjunction of A187813 with A239708. This means that a number m is a term if and only if there is a base b > 2 such that the base-b digit sum of m is b.
(End)

Crossrefs

Programs

  • Python
    from sympy import composite
    def A079696(n): return composite(n)+1 # Chai Wah Wu, Mar 19 2025

Formula

a(n) = A002808(n) + 1.
A239703(a(n)) > 0. - Hieronymus Fischer, Apr 10 2014

Extensions

Edited by Charles R Greathouse IV, Mar 19 2010

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]
Showing 1-8 of 8 results.