OFFSET
0,3
COMMENTS
This sequence is a self-inverse permutation of the nonnegative integers.
It is possible to build a continuous injective complex-valued function of a real-variable, say f, such that Im(f(r)) = 0 iff r is an integer and for any n in Z, f(n) = b(n) (see illustration in Links section).
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..6560
Rémy Sigrist, Representation in the complex plane of a function f as described in Comments section (the corresponding curve divides the complex plane into two simply connected regions rendered with different colors)
FORMULA
a(n) = n iff abs(n - 3^x) <= 1 for some x >= 0.
EXAMPLE
For n = 3:
- we have 3^1 < 2*3 < 3^(1+1),
- so b(3) = b(3 - 3) - 3 = 0 - 3 = -3,
- a(3) = abs(b(3)) = 3.
PROG
(PARI) b(n) = { if (n<0, return (-b(-n)), n==0, return (0), n==1, return (1), for (x=1, oo, my (w=3^x, h=w\2); if (w<2*n && 2*n<3*w, return (b(w-n)-w)))) }
a(n) = abs(b(n))
CROSSREFS
KEYWORD
nonn
AUTHOR
Rémy Sigrist, Oct 29 2020
STATUS
approved