%I #23 Feb 26 2020 14:41:29
%S 0,1,2,1,2,5,5,2,5,6,4,5,0,1,2,5,9,10,6,17,17,4,17,2,5,0,1,2,5,26,26,
%T 5,26,31,17,2,5,26,14,37,17,38,26,17,20,33,9,34,30,1,2,5,26,29,17,10,
%U 44,23,58,5,26,57,37,26,27,4,17,18,49,22,59,26,20,31,62,45,24
%N a(1) = 0; thereafter a(n) = (a(n-1)^2+1) mod n.
%C Does the value 0 appear infinitely many times? - _Rémy Sigrist_, Dec 16 2019
%C From _Michael De Vlieger_, Jan 26 2020: (Start)
%C Observations based on a(n) for 1 <= n <= 300000:
%C The value 0 appears at indices n = {1, 13, 26, 89, 205, 530, 2041, 276205, ...}.
%C The value 1 appears at indices n = {2, 4, 14, 27, 50, 90, 99, 175, 188, 206, 531, 2042, 5445, 6845, 7200, 18225, 24389, 25215, 37538, 46875, 48672, 53066, 79527, 93900, 147875, 176267, 186576, 196025, 254457, 276206, ...}. Let M be the indices in a(n) where 1 appears.
%C The subsequence {1, 2, 5, 26} appears with the first term at index n = 27, and apparently for all subsequent indices listed n M.
%C The subsequence {1, 2, 5, 26, 677} appears with the first term at index n = 2042, and apparently for all subsequent indices listed n M.
%C A stable next term in the subsequence S = {1, 2, 5, 26, 677} is not yet apparent, given 300000 terms of a(n). (End)
%H Rémy Sigrist, <a href="/A330405/b330405.txt">Table of n, a(n) for n = 1..10000</a>
%F a(1) = 0; a(n) = (a(n-1)^2+1) mod n.
%e a(1) = 0; a(2) = (0^2+1) mod 2 = 1; a(3) = (1^2+1) mod 2 = 2.
%t Nest[Append[#1, Mod[#1[[#2 - 1]]^2 + 1, #2]] & @@ {#, Length@ # + 1} &, {0}, 76] (* _Michael De Vlieger_, Dec 16 2019 *)
%o (PARI) v=0; for (n=1, 77, print1 (v=(v^2+1)%n", ")) \\ _Rémy Sigrist_, Dec 16 2019
%Y Cf. A003095, A064434.
%K easy,nonn
%O 1,3
%A _Matthew Ryan_, Dec 12 2019
|