%I #18 Jul 17 2024 20:28:36
%S 0,1,0,3,2,5,4,1,0,9,8,11,10,7,0,15,14,17,16,13,6,3,2,23,22,1,0,27,26,
%T 29,28,25,0,33,32,35,34,31,24,21,2,41,40,1,0,45,44,47,46,43,0,51,50,
%U 53,52,49,42,39,20,5,4,1,0,63,62,65,64,61,0,69,68,71
%N a(0) = 0; a(n) = a(a(n-1))-1 mod (n+1) for all n >= 1.
%C Question: Does every nonnegative integer appear in the sequence? Furthermore, does every nonnegative integer appear an infinite number of times?
%H Curtis Bechtel, <a href="/A363447/b363447.txt">Table of n, a(n) for n = 0..10000</a>
%e For n = 1, we have a(1) = a(a(0))-1 mod 2 = a(0)-1 mod 2 = 0-1 mod 2 = 1.
%e For n = 20, assume we already know that a(19) = 13 and a(13) = 7. Then a(20) = a(a(19))-1 mod 21 = a(13)-1 mod 21 = 6.
%e For n = 23, assume we already know that a(22) = 2 and a(2) = 0. Then a(23) = a(a(22))-1 mod 24 = a(2)-1 mod 24 = -1 mod 24 = 23.
%t a[0]:=0; a[n_]:=a[n]=Mod[a[a[n-1]]-1, n+1]; Array[a,72,0]
%o (Python)
%o a = [0]
%o for i in range(1, 100):
%o a.append((a[a[i - 1]] - 1) % (i + 1))
%Y Cf. A145465, A268176.
%K nonn,easy,look
%O 0,4
%A _Curtis Bechtel_, Jun 02 2023