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

A257726 a(0)=0; a(2n) = unlucky(a(n)), a(2n+1) = lucky(a(n)+1), where lucky = A000959, unlucky = A050505.

Original entry on oeis.org

0, 1, 2, 3, 4, 7, 5, 9, 6, 13, 11, 25, 8, 15, 14, 33, 10, 21, 19, 51, 17, 43, 35, 115, 12, 31, 22, 67, 20, 63, 45, 163, 16, 37, 29, 93, 27, 79, 66, 273, 24, 73, 57, 223, 47, 171, 146, 723, 18, 49, 42, 151, 30, 99, 88, 385, 28, 87, 83, 349, 59, 235, 203, 1093, 23, 69, 50, 193, 40, 135, 119, 559, 38, 129, 102, 475, 86, 367, 335, 1983, 34, 111
Offset: 0

Views

Author

Antti Karttunen, May 06 2015

Keywords

Comments

This sequence can be represented as a binary tree. Each left hand child is produced as A050505(n), and each right hand child as A000959(1+n), when a parent contains n >= 1:
0
|
...................1...................
2 3
4......../ \........7 5......../ \........9
/ \ / \ / \ / \
/ \ / \ / \ / \
/ \ / \ / \ / \
6 13 11 25 8 15 14 33
10 21 19 51 17 43 35 115 12 31 22 67 20 63 45 163
etc.
Because all lucky numbers are odd, it means that even terms can only occur in even positions (together with odd unlucky numbers, for each one of which there is a separate infinite cycle), while terms in odd positions are all odd.

Crossrefs

Inverse: A257725.
Related or similar permutations: A237126, A246378, A257728, A257731, A257733, A257801.
Cf. also A183089 (another similar permutation, but with a slightly different definition, resulting the first differing term at n=9, where a(9) = 13, while A183089(9) = 21).
Cf. also A257735 - A257738.

Formula

a(0)=0; after which, a(2n) = A050505(a(n)), a(2n+1) = A000959(a(n)+1).
As a composition of other permutations. For all n >= 1:
a(n) = A257731(A246378(n)).
a(n) = A257733(A237126(n)).
a(n) = A257801(A257728(n)).

A257725 Permutation of natural numbers: a(0) = 0, a(lucky(n)) = 1 + 2*a(n-1), a(unlucky(n)) = 2*a(n), where lucky(n) = n-th lucky number A000959, unlucky(n) = n-th unlucky number A050505.

Original entry on oeis.org

0, 1, 2, 3, 4, 6, 8, 5, 12, 7, 16, 10, 24, 9, 14, 13, 32, 20, 48, 18, 28, 17, 26, 64, 40, 11, 96, 36, 56, 34, 52, 25, 128, 15, 80, 22, 192, 33, 72, 112, 68, 104, 50, 21, 256, 30, 160, 44, 384, 49, 66, 19, 144, 224, 136, 208, 100, 42, 512, 60, 320, 88, 768, 29, 98, 132, 38, 27, 288, 65, 448, 272, 416, 41, 200, 97, 84, 1024, 120, 37
Offset: 0

Views

Author

Antti Karttunen, May 06 2015

Keywords

Comments

In other words, after a(0) = 0, if n is the k-th lucky number [i.e., n = A000959(k)], a(n) = 1 + 2*a(k-1); otherwise, when n is the k-th unlucky number [i.e., n = A050505(k)], a(n) = 2*a(k).
Because all lucky numbers are odd, it means that odd numbers occur in odd positions only (together with some even numbers, for each one of which there is a separate infinite cycle), while the even positions contain only even numbers.

Crossrefs

Inverse: A257726.
Related or similar permutations: A237427, A246377, A257732, A257734.
Cf. also A257690 (another similar permutation, but with a slightly different definition, resulting the first differing term at n=13, where a(13) = 9, while A257690(13) = 11).
Cf. also A257735 - A257738.

Formula

a(0) = 0; for n >= 1: if A145649(n) = 1 [i.e., if n is lucky], then a(n) = 1+(2*a(A109497(n)-1)), otherwise a(n) = 2*a(n-A109497(n)). [Where A109497(n) gives the number of lucky numbers <= n.]
As a composition of other permutations. For all n >= 1:
a(n) = A246377(A257732(n)).
a(n) = A237427(A257734(n)).

Extensions

Formula in name corrected by Antti Karttunen, Jan 10 2016

A183089 Tree generated by the lucky numbers: a(1) = 1; a(2n) = unlucky(a(n)), a(2n+1) = lucky(a(n+1)), where lucky = A000959, unlucky = A050505.

Original entry on oeis.org

1, 2, 3, 4, 7, 5, 9, 6, 21, 11, 13, 8, 31, 14, 15, 10, 87, 29, 37, 17, 49, 19, 25, 12, 141, 42, 51, 20, 63, 22, 33, 16, 517, 112, 133, 40, 189, 50, 69, 24, 259, 64, 75, 27, 111, 35, 43, 18, 925, 177, 211, 56, 267, 66, 79, 28, 339, 83, 93, 30, 159, 45, 67, 23, 4129, 618, 685, 143, 855, 167, 201, 54, 1275, 234, 261, 65, 391, 90, 105, 34
Offset: 1

Views

Author

Clark Kimberling, Dec 24 2010

Keywords

Comments

A permutation of the positive integers. See the comment at A183079.

Examples

			Top 6 levels of the binary tree:
                                     1
                                     |
                  ...................2...................
                 3                                       4
       7......../ \........5                   9......../ \........6
      / \                 / \                 / \                 / \
     /   \               /   \               /   \               /   \
    /     \             /     \             /     \             /     \
  21       11         13       8          31       14         15       10
87  29   37  17     49  19   25 12     141  42   51  20     63  22   33  16
...
From the level 3 to the level 4: 3 --> (7,5) and 4 --> (9,6).
		

Crossrefs

Inverse permutation: A257690.
Cf. A257726 (similar permutation with a slightly different definition, resulting the first differing term at n=9, where a(9) = 21, while A257726(9) = 13), A257735 - A257738.
Cf. A183079, A237739 (other similar permutations).

Formula

Let L(n) = A000959(n), the n-th lucky number.
Let U(n) = A050505(n), the n-th unlucky numbers.
The tree-array T(n,k) is then given by rows:
T(0,0) = 1; T(1,0) = 2;
T(n,2j) = L(T(n-1),j);
T(n,2j+1) = U(T(n-1),j);
for j = 0, 1, ..., 2^(n-1) - 1, n >= 2.
a(1) = 1; a(2n) = A050505(a(n)), a(2n+1) = A000959(a(n+1)). - Antti Karttunen, May 09 2015

Extensions

Added a formula to the Name field and more terms, edited Example section - Antti Karttunen, May 09 2015

A257731 Permutation of natural numbers: a(1) = 1, a(prime(n)) = lucky(1+a(n)), a(composite(n)) = unlucky(a(n)), where prime(n) = n-th prime number A000040, composite(n) = n-th composite number A002808 and lucky = A000959, unlucky = A050505.

Original entry on oeis.org

1, 3, 9, 2, 33, 5, 7, 14, 4, 45, 163, 8, 15, 11, 20, 6, 25, 59, 63, 203, 12, 22, 13, 17, 28, 10, 35, 78, 235, 83, 1093, 251, 18, 30, 19, 24, 31, 39, 16, 47, 67, 101, 43, 290, 107, 1283, 87, 309, 26, 41, 27, 34, 21, 42, 53, 23, 61, 88, 115, 128, 321, 57, 354, 137, 1499, 112, 349, 376, 36, 55, 1401, 38, 49, 46, 29, 56, 70, 32, 99, 81
Offset: 1

Views

Author

Antti Karttunen, May 06 2015

Keywords

Crossrefs

Inverse: A257732.
Related or similar permutations: A246377, A255421, A257726, A257733.
Cf. also A032600, A255553, A255554.
Differs from A257733 for the first time at n=19, where a(19) = 63, while A257733(19) = 203.

Formula

a(1) = 1; for n > 1: if A010051(n) = 1 [i.e., if n is a prime], then a(n) = A000959(1+a(A000720(n))), otherwise a(n) = A050505(a(A065855(n))).
As a composition of other permutations:
a(n) = A257726(A246377(n)).
a(n) = A257733(A255421(n)).

A257732 Permutation of natural numbers: a(1) = 1, a(lucky(n)) = prime(a(n-1)), a(unlucky(n)) = composite(a(n)), where lucky(n) = n-th lucky number A000959, unlucky(n) = n-th unlucky number A050505, and prime = A000040, composite = A002808.

Original entry on oeis.org

1, 4, 2, 9, 6, 16, 7, 12, 3, 26, 14, 21, 23, 8, 13, 39, 24, 33, 35, 15, 53, 22, 56, 36, 17, 49, 51, 25, 75, 34, 37, 78, 5, 52, 27, 69, 101, 72, 38, 102, 50, 54, 43, 106, 10, 74, 40, 94, 73, 134, 83, 98, 55, 135, 70, 76, 62, 141, 18, 100, 57, 125, 19, 99, 175, 114, 41, 130, 167, 77, 176, 95, 89, 104, 137, 86, 184, 28, 149, 133, 80, 164, 30
Offset: 1

Views

Author

Antti Karttunen, May 06 2015

Keywords

Comments

In other words, a(1) = 1 and for n > 1, if n is the k-th lucky number larger than 1 [i.e., n = A000959(k+1)] then a(n) = nthprime(a(k)), otherwise, when n is the k-th unlucky number [i.e., n = A050505(k)], then a(n) = nthcomposite(a(k)).

Crossrefs

Inverse: A257731.
Related or similar permutations: A246378, A255422, A257725, A257734.
Cf. also A032600, A255553, A255554.

Formula

a(1) = 1; for n > 1: if A145649(n) = 1 [i.e., if n is lucky], then a(n) = A000040(a(A109497(n)-1)), otherwise a(n) = A002808(a(n-A109497(n))).
As a composition of other permutations:
a(n) = A246378(A257725(n)).
a(n) = A255422(A257734(n)).

A257690 Permutation of natural numbers: a(1) = 1, a(lucky(n)) = (2*a(n))-1, a(unlucky(n)) = 2*n, where lucky(n) = n-th lucky number A000959, unlucky(n) = n-th unlucky number A050505.

Original entry on oeis.org

1, 2, 3, 4, 6, 8, 5, 12, 7, 16, 10, 24, 11, 14, 15, 32, 20, 48, 22, 28, 9, 30, 64, 40, 23, 96, 44, 56, 18, 60, 13, 128, 31, 80, 46, 192, 19, 88, 112, 36, 120, 26, 47, 256, 62, 160, 92, 384, 21, 38, 27, 176, 224, 72, 240, 52, 94, 512, 124, 320, 184, 768, 29, 42, 76, 54, 63, 352, 39, 448, 144, 480, 95, 104, 43, 188, 1024, 248, 55
Offset: 1

Views

Author

Antti Karttunen, May 09 2015

Keywords

Crossrefs

Inverse permutation: A183089.
Cf. also A257725 (similar permutation with a slightly different definition, resulting the first differing term at n=13, where a(13) = 11, while A257725(13) = 9).
Cf. also A257735 - A257738.

Formula

a(1) = 1; for n > 1: if A145649(n) = 1 [i.e., if n is lucky], then a(n) = (2*a(A109497(n)))-1, otherwise a(n) = 2*a(n-A109497(n)). [Where A109497(n) gives the number of lucky numbers <= n.]

A257733 Permutation of natural numbers: a(1) = 1, a(ludic(n)) = lucky(1+a(n-1)), a(nonludic(n)) = unlucky(a(n)), where ludic(n) = n-th ludic number A003309, nonludic(n) = n-th nonludic number A192607 and lucky = A000959, unlucky = A050505.

Original entry on oeis.org

1, 3, 9, 2, 33, 5, 7, 14, 4, 45, 163, 8, 15, 11, 20, 6, 25, 59, 203, 12, 22, 17, 63, 28, 13, 10, 35, 78, 235, 251, 18, 30, 24, 83, 39, 19, 1093, 16, 47, 101, 31, 290, 67, 309, 26, 41, 43, 34, 107, 53, 27, 1283, 87, 23, 61, 128, 42, 354, 88, 376, 21, 36, 55, 57, 46, 137, 115, 70, 38, 1499, 321, 112, 32, 81, 161, 56, 1401, 430, 113, 454, 29, 48, 49
Offset: 1

Views

Author

Antti Karttunen, May 06 2015

Keywords

Crossrefs

Inverse: A257734.
Related or similar permutations: A237427, A255422, A257726, A257731.
Cf. also A256486, A256487.
Differs from A257731 for the first time at n=19, where a(19) = 203, while A257731(19) = 63.

Formula

a(1) = 1; for n > 1: if A192490(n) = 1 [i.e., if n is ludic], then a(n) = A000959(1+a(A192512(n)-1)), otherwise a(n) = A050505(a(A236863(n))).
As a composition of other permutations:
a(n) = A257731(A255422(n)).
a(n) = A257726(A237427(n)).

A257734 Permutation of natural numbers: a(1) = 1, a(lucky(n)) = ludic(1+a(n-1)), a(unlucky(n)) = nonludic(a(n)), where lucky(n) = n-th lucky number A000959, unlucky(n) = n-th unlucky number A050505, and ludic = A003309, nonludic = A192607.

Original entry on oeis.org

1, 4, 2, 9, 6, 16, 7, 12, 3, 26, 14, 20, 25, 8, 13, 38, 22, 31, 36, 15, 61, 21, 54, 33, 17, 45, 51, 24, 81, 32, 41, 73, 5, 48, 27, 62, 119, 69, 35, 105, 46, 57, 47, 96, 10, 65, 39, 82, 83, 151, 115, 92, 50, 135, 63, 76, 64, 124, 18, 86, 55, 106, 23, 108, 189, 146, 43, 118, 193, 68, 169, 84, 91, 100, 149, 85, 156, 28, 179, 111, 74, 136, 34
Offset: 1

Views

Author

Antti Karttunen, May 06 2015

Keywords

Crossrefs

Inverse: A257733.
Related or similar permutations: A237126, A255421, A257725, A257732.
Cf. also A256486, A256487.

Formula

a(1) = 1; for n > 1: if A145649(n) = 1 [i.e., if n is lucky], then a(n) = A003309(1+a(A109497(n)-1)), otherwise a(n) = A192607(a(n-A109497(n))).
As a composition of other permutations:
a(n) = A255421(A257732(n)).
a(n) = A237126(A257725(n)).

A166744 Unlucky primes: numbers which are members of both A000040 (primes) and A050505 (unlucky).

Original entry on oeis.org

2, 5, 11, 17, 19, 23, 29, 41, 47, 53, 59, 61, 71, 83, 89, 97, 101, 103, 107, 109, 113, 131, 137, 139, 149, 157, 167, 173, 179, 181, 191, 197, 199, 227, 229, 233, 239, 251, 257, 263, 269, 271, 277, 281, 293, 311, 313, 317, 337, 347, 353, 359, 373, 379, 383, 389
Offset: 1

Views

Author

Gabriel Finch (salsaman(AT)xs4all.nl), Oct 21 2009

Keywords

Comments

There are infinitely many unlucky prime numbers, in particular all those of the form 6n - 1, eliminated in the second step of Ulam's procedure for lucky numbers. - Davide Rotondo, Aug 31 2020

Crossrefs

Cf. A007528, A031157 (lucky primes).

Programs

  • Maple
    L:= [seq(2*i+1, i=0..10^3)]:
    for n from 2 while n < nops(L) do
      r:= L[n];
      L:= subsop(seq(r*i=NULL, i=1..nops(L)/r), L);
    od:
    U:= {2, seq(i,i=3..2*10^3+1,2)} minus convert(L,set):
    sort(convert(select(isprime,U),list)); # Robert Israel, Jul 26 2019
  • SageMath
    # Copy from  A000959 - (Robert FERREOL, Nov 19 2014)
    def lucky(n):
      L=list(range(1, n+1, 2)); j=1
      while L[j] <= len(L)-1:
        L=[L[i] for i in range(len(L)) if (i+1)%L[j]!=0]
        j+=1
      return(L)
    [ p for p in prime_range(1000) if p not in lucky(1000) ] # Hauke Löffler, Jul 26 2019

A000959 Lucky numbers.

Original entry on oeis.org

1, 3, 7, 9, 13, 15, 21, 25, 31, 33, 37, 43, 49, 51, 63, 67, 69, 73, 75, 79, 87, 93, 99, 105, 111, 115, 127, 129, 133, 135, 141, 151, 159, 163, 169, 171, 189, 193, 195, 201, 205, 211, 219, 223, 231, 235, 237, 241, 259, 261, 267, 273, 283, 285, 289, 297, 303
Offset: 1

Views

Author

N. J. A. Sloane; entry updated Mar 07 2008

Keywords

Comments

An interesting general discussion of the phenomenon of 'random primes' (generalizing the lucky numbers) occurs in Hawkins (1958). Heyde (1978) proves that Hawkins' random primes do not only almost always satisfy the Prime Number Theorem but also the Riemann Hypothesis. - Alf van der Poorten, Jun 27 2002
Bui and Keating establish an asymptotic formula for the number of k-difference twin primes, and more generally to all l-tuples, of Hawkins primes, a probabilistic model of the Eratosthenes sieve. The formula for k = 1 was obtained by Wunderlich [Acta Arith. 26 (1974), 59 - 81]. - Jonathan Vos Post, Mar 24 2009. (This is quoted from the abstract of the Bui-Keating (2006) article, Joerg Arndt, Jan 04 2014)
It appears that a 1's line is formed, as in the Gilbreath's conjecture, if we use 2 (or 4), 3, 5 (differ of 7), 9, 13, 15, 21, 25, ... instead of A000959 1, 3, 7, 9, 13, 15, 21, 25, ... - Eric Desbiaux, Mar 25 2010
The Mersenne primes 2^p - 1 (= A000668, p in A000043) are in this sequence for p = 2, 3, 5, 7, 13, 17, and 19, but not for the following exponents p = 31, 61, and 89. - M. F. Hasler, May 06 2025

References

  • Martin Gardner, Gardner's Workout, Chapter 21 "Lucky Numbers and 2187" pp. 149-156 A. K. Peters MA 2002.
  • Richard K. Guy, Unsolved Problems in Number Theory, C3.
  • C. S. Ogilvy, Tomorrow's Math. 2nd ed., Oxford Univ. Press, 1972, p. 99.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
  • M. L. Stein and P. R. Stein, Tables of the Number of Binary Decompositions of All Even Numbers Less Than 200,000 into Prime Numbers and Lucky Numbers. Report LA-3106, Los Alamos Scientific Laboratory of the University of California, Los Alamos, NM, Sep 1964.
  • James J. Tattersall, Elementary Number Theory in Nine Chapters, Cambridge University Press, 1999, page 116.
  • David Wells, The Penguin Dictionary of Curious and Interesting Numbers. Penguin Books, NY, 1986, 114.

Crossrefs

Main diagonal of A258207.
Column 1 of A255545. (cf. also arrays A255543, A255551).
Cf. A050505 (complement).
Cf. A145649 (characteristic function).
Cf. A031883 (first differences), A254967 (iterated absolute differences), see also A054978.
Cf. A109497 (works as a left inverse function).
The Gilbreath transform is A054978 - see also A362460, A362461, A362462.

Programs

  • Haskell
    a000959 n = a000959_list !! (n-1)
    a000959_list =  1 : sieve 2 [1,3..] where
       sieve k xs = z : sieve (k + 1) (lucky xs) where
          z = xs !! (k - 1 )
          lucky ws = us ++ lucky vs where
                (us, _:vs) = splitAt (z - 1) ws
    -- Reinhard Zumkeller, Dec 05 2011
    
  • Haskell
    -- Also see links.
    (C++) // See Wilson link, Nov 14 2012
    
  • Maple
    ## luckynumbers(n) returns all lucky numbers from 1 to n. ## Try n=10^5 just for fun. luckynumbers:=proc(n) local k, Lnext, Lprev; Lprev:=[$1..n]; for k from 1 do if k=1 or k=2 then Lnext:= map(w-> Lprev[w],remove(z -> z mod Lprev[2] = 0,[$1..nops(Lprev)])); if nops(Lnext)=nops(Lprev) then break fi; Lprev:=Lnext; else Lnext:= map(w-> Lprev[w],remove(z -> z mod Lprev[k] = 0,[$1..nops(Lprev)])); if nops(Lnext)=nops(Lprev) then break fi; Lprev:=Lnext; fi; od; return Lnext; end: # Walter Kehowski, Jun 05 2008; typo fixed by Robert Israel, Nov 19 2014
    # Alternative
    A000959List := proc(mx) local i, L, n, r;
    L:= [seq(2*i+1, i=0..mx)]:
    for n from 2 while n < nops(L) do
      r:= L[n];
      L:= subsop(seq(r*i=NULL, i=1..nops(L)/r), L);
    od: L end:
    A000959List(10^3); # Robert Israel, Nov 19 2014
  • Mathematica
    luckies = 2*Range@200 - 1; f[n_] := Block[{k = luckies[[n]]}, luckies = Delete[luckies, Table[{k}, {k, k, Length@luckies, k}]]]; Do[f@n, {n, 2, 30}]; luckies (* Robert G. Wilson v, May 09 2006 *)
    sieveMax = 10^6; luckies = Range[1, sieveMax, 2]; sieve[n_] := Module[{k = luckies[[n]]}, luckies = Delete[luckies, Table[{i}, {i, k, Length[luckies], k}]]]; n = 1; While[luckies[[n]] < Length[luckies], n++; sieve[n]]; luckies
    L = Table[2*i + 1, {i, 0, 10^3}]; For[n = 2, n < Length[L], r = L[[n++]]; L = ReplacePart[L, Table[r*i -> Nothing, {i, 1, Length[L]/r}]]]; L (* Jean-François Alcover, Mar 15 2016, after Robert Israel *)
  • PARI
    A000959_upto(nMax)={my(v=vectorsmall(nMax\2,k,2*k-1),i=1,q);while(v[i++]<=#v,v=vecextract(v,2^#v-1-(q=1<M. F. Hasler, Sep 22 2013, improved Jan 20 2020
    
  • Python
    def lucky(n):
        L = list(range(1, n + 1, 2))
        j = 1
        while j <= len(L) - 1 and L[j] <= len(L):
            del L[L[j]-1::L[j]]
            j += 1
        return L
    # Robert FERREOL, Nov 19 2014, corrected by F. Chapoton, Mar 29 2020, performance improved by Ely Golden, Aug 18 2022
    
  • Scheme
    (define (A000959 n) ((rowfun_n_for_A000959sieve n) n)) ;; Code for rowfun_n_for_A000959sieve given in A255543.
    ;; Antti Karttunen, Feb 26 2015

Formula

Start with the natural numbers. Delete every 2nd number, leaving 1 3 5 7 ...; the 2nd number remaining is 3, so delete every 3rd number, leaving 1 3 7 9 13 15 ...; now delete every 7th number, leaving 1 3 7 9 13 ...; now delete every 9th number; etc.
a(n) = A254967(n-1, n-1). - Reinhard Zumkeller, Feb 11 2015
a(n) = A258207(n,n). [Where A258207 is a square array constructed from the numbers remaining after each step described above.] - Antti Karttunen, Aug 06 2015
A145649(a(n)) = 1; complement of A050505. - Reinhard Zumkeller, Oct 15 2008
Other identities from Antti Karttunen, Feb 26 2015: (Start)
For all n >= 1, A109497(a(n)) = n.
For all n >= 1, a(n) = A000040(n) + A032600(n).
For all n >= 2, a(n) = A255553(A000040(n)). (End)
Showing 1-10 of 24 results. Next