OFFSET
1,3
COMMENTS
Note the indexing: the domain starts from 1, while the range includes also zero.
Has an infinite number of infinite cycles. See comments at A246681.
LINKS
FORMULA
a(1) = 0, a(2) = 1, and for n > 1, a(2n) = nthcomposite(a(n)), a(2n-1) = nthprime(a(A064989(2n-1))), where nthprime = A000040, nthcomposite = A002808, and A064989(n) shifts the prime factorization of n one step towards smaller primes.
As a composition of related permutations:
Other identities.
For all n >= 1 the following holds:
For all n > 1 the following holds:
PROG
(PARI)
default(primelimit, (2^31)+(2^30));
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)};
for(n=1, 46, write("b246682.txt", n, " ", A246682(n)));
(Scheme, two variants)
CROSSREFS
Inverse: A246681.
KEYWORD
nonn
AUTHOR
Antti Karttunen, Sep 01 2014
STATUS
approved