%I #9 May 28 2019 19:31:23
%S 0,2,1,6,5,9,8,11,10,10,9,12,11,14,13,11,10,15,14,12,11,14,13,18,17,
%T 15,14,19,18,21,20,10,9,22,21,11,10,13,12,17,16,14,13,18,17,20,19,15,
%U 14,21,20,16,15,18,17,21,20,19,18,22,21,24,23,14,13,25,24
%N For any Gaussian integer z, let f(z) = z / (1+i) when z is a multiple of 1+i and f(z) = z+1 otherwise (where i denotes the imaginary unit). a(n) gives the number of iterations of the map f, starting with n, needed to reach a cycle.
%C Iterating the map f always ends in one of the following cycles: (0) or (-i, -i+1).
%C We can build a variant of this sequence by replacing the constant 1+i appearing in the name by any Gaussian integer, say d, such that gcd(Re(d), Im(d)) = 1 and norm(d) > 1.
%C This sequence has similarities with A061313.
%H Rémy Sigrist, <a href="/A308431/a308431.png">Colored representation of the number of iterations of the map f, starting with x+i*y, needed to reach a cycle for x = -500..+500 and y = -500..+500</a>
%H Rémy Sigrist, <a href="/A308431/a308431_1.png">Colored representation of the variant where d = 2-i</a>
%e For n = 4:
%e - 4 is a multiple of 1+i, hence f(4) = 4/(1+i) = 2-2*i,
%e - 2-2*i is a multiple of 1+i, hence f(2-2*i) = (2-2*i)/(1+i) = -2*i,
%e - -2*i is a multiple of 1+i, hence f(-2*i) = -2*i/(1+i) = -1-i,
%e - -1-i is a multiple of 1+i, hence f(-1-i) = (-1-i)/(1+i) = -1,
%e - -1 is not multiple of 1+i, hence f(-1) = -1+1 = 0,
%e - 0 belongs to the cycle (0), hence a(4) = 5.
%o (PARI) a(z) = for (k=0, oo, if (z==0||z==-I||z==-I+1, return (k), if ((real(z)+imag(z))%2, z++, z/=(1+I))))
%Y Cf. A061313.
%K nonn
%O 0,2
%A _Rémy Sigrist_, May 26 2019