login
A267107
"Chebyshev's bat permutation": a(1) = 1, a(A080147(n)) = A080148(a(n)), a(A080148(n)) = A080147(a(n)).
8
1, 3, 2, 7, 6, 5, 4, 16, 13, 14, 12, 11, 9, 10, 35, 8, 29, 31, 30, 26, 23, 25, 21, 27, 22, 20, 24, 74, 17, 19, 18, 62, 67, 66, 15, 65, 54, 57, 51, 58, 55, 56, 45, 48, 43, 59, 50, 44, 53, 47, 39, 152, 49, 37, 41, 42, 38, 40, 46, 144, 130, 32, 139, 137, 36, 34, 33, 118, 136, 129, 128, 113, 121, 28, 108, 122, 125
OFFSET
1,2
COMMENTS
This is a self-inverse permutation of natural numbers.
FORMULA
a(1) = 1; and for n > 1, if prime(n) modulo 4 = 1, a(n) = A080148(a(A267097(n))), otherwise a(n) = A080147(a(A267098(n))).
PROG
(PARI)
allocatemem(2^30);
default(primelimit, 4294965247);
uplim = 2^20;
uplim2 = 366824; \\ Very ad hoc.
v080147 = vector(uplim);
v080148 = vector(uplim);
v267097 = vector(uplim);
v267107 = vector(uplim);
v267097[1] = 0; c = 0; v47i = 0; v48i = 0; for(n=2, uplim, if((1 == (prime(n)%4)), c++; v47i++; v080147[v47i] = n, v48i++; v080148[v48i] = n); v267097[n] = c; if(!(n%32768), print1(" n=", n)));
A080147(n) = v080147[n];
A080148(n) = v080148[n];
A267097(n) = v267097[n];
A267098(n) = (n - A267097(n))-1;
A267107(n) = v267107[n];
v267107[1] = 1; for(n=2, uplim2, if((1 == (prime(n) % 4)), v267107[n] = A080148(A267107(A267097(n))), v267107[n] = A080147(A267107(A267098(n)))); if(!(n%32768), print1(" n=", n)));
for(n=1, uplim2, write("b267107.txt", n, " ", A267107(n)));
(Scheme, with memoization-macro definec)
(definec (A267107 n) (cond ((<= n 1) n) ((= 1 (modulo (A000040 n) 4)) (A080148 (A267107 (A267097 n)))) (else (A080147 (A267107 (A267098 n))))))
CROSSREFS
Cf. A268393 (record positions), A268394 (record values).
Cf. A267100, A267105, A267106 and also A270193, A270194, A270199, A270201, A270202 for other similarly constructed permutations based on prime distribution biases.
Sequence in context: A054429 A269398 A269397 * A126316 A101224 A348366
KEYWORD
nonn,look
AUTHOR
Antti Karttunen, Feb 01 2016
EXTENSIONS
Name changed, the old name was "Manta moth permutation" - Antti Karttunen, Dec 10 2019
STATUS
approved