OFFSET
1,2
COMMENTS
Note that this is the maximum over all possible initial z.
From Robert Israel, Aug 29 2016: (Start)
If n is divisible by 4, then a(n) = a(n/2).
In particular, a(n) = 2 if n > 1 is a power of 2.
Are there any other n with a(n) = 2? (End)
EXAMPLE
For n = 3, c = 2+i:
z_0 = 0.
z_1 = (z_0)^2 + 2+i = 2+ i (mod 3).
z_2 = (z_1)^2 + 2+i = 2+2i (mod 3).
z_3 = (z_2)^2 + 2+i = 2 (mod 3).
z_4 = (z_3)^2 + 2+i = i (mod 3).
z_5 = (z_4)^2 + 2+i = 1+ i (mod 3).
z_6 = (z_5)^2 + 2+i = 2 (mod 3) = z_3.
So the eventual period is 3, which is the maximum possible over all c and z_0 when n = 3.
MAPLE
f:= proc(N)
local pmax, R, S, T, z, a, b, c, x, y, found, zpd, count;
pmax:= 0;
for a from 0 to N-1 do
for b from 0 to N-1 do
c:= a+b*I;
S:= {}:
for x from 0 to N-1 do
for y from 0 to N-1 do
z:= x+I*y;
if not member(z, S) then
T:= {z};
R[z]:= 0;
found:= false;
for count from 1 do
z:= expand(z^2 + c) mod N;
if member(z, S) then break fi;
if member(z, T) then found:= true; zpd:= count - R[z]; break fi;
R[z]:= count;
T:= T union {z};
od;
S:= S union T;
if found and zpd > pmax then
pmax:= zpd fi;
fi;
od od;
od od;
pmax
end proc:
map(f, [$1..30]); # Robert Israel, Aug 29 2016
MATHEMATICA
f[n_] := Module[{pmax = 0, R, S, T, z, a, b, c, x, y, found, zpd, count},
For[a = 0, a <= n - 1, a++,
For[b = 0, b <= n - 1, b++, c = a + b*I; S = {};
For[x = 0, x <= n - 1, x++,
For[y = 0, y <= n - 1, y++, z = x + y*I;
If[!MemberQ[S, z], T = {z}; R[z] = 0; found = False;
For[count = 1, True, count++,
z = Mod[Expand[z^2 + c], n];
If[MemberQ[S, z], Break[] ];
If [MemberQ[T, z], found = True; zpd = count -
R[z]; Break[]]; R[z] = count;
T = Union[T, {z}]]; S = Union[S, T];
If [found && zpd > pmax, pmax = zpd]]]]]];
pmax];
Table[f[n], {n, 1, 20}] (* Jean-François Alcover, May 12 2023, after Robert Israel *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Luke Palmer, Aug 21 2016
EXTENSIONS
More terms from Robert Israel, Aug 29 2016
STATUS
approved