OFFSET
0,3
COMMENTS
This integer sequence exists if and only if the Collatz conjecture is true. The proof is relatively trivial.
This is -3 times the Q function from Rozier restricted to the natural numbers.
The only multiple of 3 in the sequence is 0.
LINKS
Richard N. Smith, Table of n, a(n) for n = 0..2000
Olivier Rozier, Parity sequences of the 3x+1 map on the 2-adic integers and Euclidean embedding, arXiv:1805.00133 [math.DS], 2018.
FORMULA
EXAMPLE
For n = 0, the equation a(0) = 2*a(0) implies a(0) = 0.
For n = 1, the equation becomes a(1) = -3 + 2*a(2) = -3 + 4*a(1), so a(1) = 1.
For n = 3, a bit more calculating gives a(3) = -3 + 2*a(5) = -9 + 4*a(8) = -9 + 32*a(1) = 23.
MAPLE
a:= proc(n) option remember; `if`(n<2, n,
`if`(irem(n, 2, 'r')=0, 2*a(r), 2*a(n+r+1)-3))
end:
seq(a(n), n=0..40); # Alois P. Heinz, Jul 14 2019
MATHEMATICA
a[n_] := a[n] = If[n < 2, n, If[EvenQ[n], 2 a[n/2], 2 a[(3n + 1)/2] - 3]];
a /@ Range[0, 50] (* Jean-François Alcover, Sep 28 2019 *)
PROG
(Python)
def a(x):
if x <= 1: return x
elif x%2: return -3 + 2 * a((3*x + 1)//2)
else: return 2*a(x//2)
(PARI) a(n)=if(n<=1, n, if(n%2, -3 + 2*a((3*n+1)/2), 2*a(n/2))) \\ Richard N. Smith, Jul 16 2019
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Jan Met den Ancxt, Jul 14 2019
STATUS
approved