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

A071574 If n = k-th prime, a(n) = 2*a(k) + 1; if n = k-th nonprime, a(n) = 2*a(k).

Original entry on oeis.org

0, 1, 3, 2, 7, 6, 5, 4, 14, 12, 15, 10, 13, 8, 28, 24, 11, 30, 9, 20, 26, 16, 29, 56, 48, 22, 60, 18, 25, 40, 31, 52, 32, 58, 112, 96, 21, 44, 120, 36, 27, 50, 17, 80, 62, 104, 57, 64, 116, 224, 192, 42, 49, 88, 240, 72, 54, 100, 23, 34, 61, 160, 124, 208, 114, 128, 19
Offset: 1

Views

Author

Christopher Eltschka (celtschk(AT)web.de), May 31 2002

Keywords

Comments

The recursion start is implicit in the rule, since the rule demands that a(1)=2*a(1). All other terms are defined through terms for smaller indices until a(1) is reached.
a(n) is a bijective mapping from the positive integers to the nonnegative integers. Given the value of a(n), you can get back to n using the following algorithm:
Start with an initial value of k=1 and write a(n) in binary representation. Then for each bit, starting with the most significant one, do the following: - if the bit is 1, replace k by the k-th prime - if the bit is 0, replace k by the k-th nonprime. After you processed the last (i.e. least significant) bit of a(n), you've got n=k.
Example: From a(n) = 12 = 1100_2, you get 1->2->3=>6=>10; a(10)=12. Here each "->" is a step due to binary digit 1; each "=>" is a step due to binary digit 0.
The following sequences all appear to have the same parity (with an extra zero term at the start of A010051): A010051, A061007, A035026, A069754, A071574. - Jeremy Gardiner, Aug 09 2002. (At least with this sequence the identity a(n) = A010051(n) mod 2 is obvious, because each prime is mapped to an odd number and each composite to an even number. - Antti Karttunen, Apr 04 2015)
For n > 1: a(n) = 2 * a(if i > 0 then i else A066246(n) + 1) + A057427(i) with i = A049084(n). - Reinhard Zumkeller, Feb 12 2014
A237739(a(n)) = n; a(A237739(n)) = n. - Reinhard Zumkeller, Apr 30 2014

Examples

			1 is the 1st nonprime, so a(1) = 2*a(1), therefore a(1) = 0.
2 is the 1st prime, so a(2) = 2*a(1)+1 = 2*0+1 = 1.
4 is the 2nd nonprime, so a(4) = 2*a(2) = 2*1 = 2.
		

Crossrefs

Inverse: A237739.
Compare also to the permutation A246377.
Same parity: A010051, A061007, A035026, A069754.

Programs

  • Haskell
    a071574 1 = 0
    a071574 n = 2 * a071574 (if j > 0 then j + 1 else a049084 n) + 1 - signum j
                where j = a066246 n
    -- Reinhard Zumkeller, Feb 12 2014
    
  • Mathematica
    a[1]=0; a[n_]:=If[PrimeQ[n],2*a[PrimePi[n]]+1,2*a[n-PrimePi[n]]];Table[a[n],{n,100}]
  • PARI
    first(n) = my(res = vector(n), p); for(x=2, n, p=isprime(x); res[x]=2*res[x*!p-(-1)^p*primepi(x)]+p); res \\ Iain Fox, Oct 19 2018
  • Scheme
    ;; With memoizing definec-macro.
    (definec (A071574 n) (cond ((= 1 n) 0) ((= 1 (A010051 n)) (+ 1 (* 2 (A071574 (A000720 n))))) (else (* 2 (A071574 (+ 1 (A065855 n)))))))
    ;; Antti Karttunen, Apr 04 2015
    

Formula

a(1) = 0, and for n > 1, if A010051(n) = 1 [when n is a prime], a(n) = 1 + 2*a(A000720(n)), otherwise a(n) = 2*a(1 + A065855(n)). - Antti Karttunen, Apr 04 2015

Extensions

Mathematica program completed by Harvey P. Dale, Nov 28 2024

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

A269848 a(1) = 1, a(2n) = A065090(1+a(n)), a(2n+1) = A000040(a(A064989(2n+1))).

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 11, 8, 7, 9, 31, 10, 127, 18, 13, 14, 709, 12, 5381, 15, 23, 45, 52711, 16, 17, 165, 19, 27, 648391, 21, 9737333, 22, 61, 856, 41, 20, 174440041, 6185, 197, 24, 3657500101, 34, 88362852307, 63, 29, 58644, 2428095424619, 25, 59, 26, 977, 212
Offset: 1

Views

Author

Antti Karttunen, Mar 06 2016

Keywords

Comments

Term a(47) manually copied from A007097(15). Note that A000040(15) = 47.

Crossrefs

Inverse: A269847.
Related or similar permutations: A237739, A243071, A246682, A269858.

Programs

  • PARI
    allocatemem(2^30);
    default(primelimit,4294965247);
    A002808(n) = { my(k=-1); while( -n + n += -k + k=primepi(n), ); n}; \\ This function from M. F. Hasler
    A064989(n) = {my(f); f = factor(n); if((n>1 && f[1,1]==2), f[1,2] = 0); for (i=1, #f~, f[i,1] = precprime(f[i,1]-1)); factorback(f)};
    A269848 = n -> if(n<=2,n,if((n%2),prime(A269848(A064989(n))),A002808(A269848(n/2)-1)));
    for(n=1, 52, t = A269848(n); print1(t,", "); write("b269848.txt", n, " ", t));
    
  • Scheme
    ;; With memoization-macro definec.
    (definec (A269848 n) (cond ((<= n 1) n) ((even? n) (A065090 (+ 1 (A269848 (/ n 2))))) (else (A000040 (A269848 (A064989 n))))))

Formula

a(1) = 1, a(2) = 2, for n > 2, if n is even, a(n) = A002808(a(n/2)-1), and for odd n, a(n) = A000040(a(A064989(n))).
As a composition of other permutations:
a(n) = A237739(A243071(n)).
Other identities. For all n >= 1:
a(A000040(n)) = A007097(n). [Maps primes to the primeth recurrence.]

A269858 Permutation of natural numbers: a(1) = 1, a(2n) = A065090(1+a(n)), a(2n+1) = A000040(a(A268674(2n+1))).

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 11, 8, 7, 9, 31, 10, 127, 18, 13, 14, 709, 12, 5381, 15, 19, 45, 52711, 16, 17, 165, 23, 27, 648391, 21, 9737333, 22, 29, 856, 41, 20, 174440041, 6185, 61, 24, 3657500101, 28, 88362852307, 63, 43, 58644, 2428095424619, 25, 59, 26, 37, 212, 75063692618249, 34, 67, 39, 47
Offset: 1

Views

Author

Antti Karttunen, Mar 06 2016

Keywords

Comments

Terms for prime positions copied from A007097.

Crossrefs

Inverse: A269857.
Related or similar permutations: A237739, A252756, A269848.

Formula

a(1) = 1, a(2) = 2, for n > 2, if n is even, a(n) = A002808(a(n/2)-1), and for odd n, a(n) = A000040(a(A268674(n))).
As a composition of other permutations:
a(n) = A237739(A252756(n)).
Other identities. For all n >= 1:
a(A000040(n)) = A007097(n). [Maps primes to the primeth recurrence.]
Showing 1-4 of 4 results.