login
A324401
Lexicographically earliest sequence such that a(i) = a(j) => f(i) = f(j) for all i, j >= 1, where f(n) = -1 if n is an odd prime, f(n) = -2 if n = 2^k, with k > 1, and f(n) = n for all other numbers.
7
1, 2, 3, 4, 3, 5, 3, 4, 6, 7, 3, 8, 3, 9, 10, 4, 3, 11, 3, 12, 13, 14, 3, 15, 16, 17, 18, 19, 3, 20, 3, 4, 21, 22, 23, 24, 3, 25, 26, 27, 3, 28, 3, 29, 30, 31, 3, 32, 33, 34, 35, 36, 3, 37, 38, 39, 40, 41, 3, 42, 3, 43, 44, 4, 45, 46, 3, 47, 48, 49, 3, 50, 3, 51, 52, 53, 54, 55, 3, 56, 57, 58, 3, 59, 60, 61, 62, 63, 3, 64, 65, 66, 67, 68, 69, 70, 3, 71, 72, 73, 3, 74, 3, 75, 76
OFFSET
1,2
COMMENTS
For all i, j:
A305801(i) = A305801(j) => a(i) = a(j),
a(i) = a(j) => A305976(i) = A305976(j) => A001221(i) = A001221(j),
a(i) = a(j) => A322591(i) = A322591(j),
a(i) = a(j) => A323235(i) = A323235(j),
a(i) = a(j) => A324399(i) = A324399(j),
a(i) = a(j) => A297159(i) = A297159(j).
LINKS
FORMULA
If n <= 2, a(n) = n, for n > 2, if n is an odd prime, a(n) = 3, if n = 2^k, with k >= 2, a(n) = 4, otherwise a(n) = 4 + n - A000523(n) - A000720(n).
PROG
(PARI)
A000523(n) = if(n<1, 0, #binary(n)-1);
A324401(n) = if(n<4, n, if(isprime(n), 3, if(!bitand(n, n-1), 4, 4+n-A000523(n)-primepi(n))));
(PARI)
up_to = 65537;
rgs_transform(invec) = { my(om = Map(), outvec = vector(length(invec)), u=1); for(i=1, length(invec), if(mapisdefined(om, invec[i]), my(pp = mapget(om, invec[i])); outvec[i] = outvec[pp] , mapput(om, invec[i], i); outvec[i] = u; u++ )); outvec; };
Aux324401(n) = if((n>2) && (isprime(n)||!bitand(n, n-1)), -(2-(n%2)), n);
\\ Equally: Aux324401(n) = if(n<=2, n, if(isprime(n), -1, if(!bitand(n, n-1), -2, n)));
v324401 = rgs_transform(vector(up_to, n, Aux324401(n)));
A324401(n) = v324401[n];
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, Mar 01 2019
STATUS
approved