This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A097031 #16 Jan 25 2024 08:02:29 %S A097031 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,1,1,1, %T A097031 1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1, %U A097031 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,2,1,1,1 %N A097031 Length of terminal cycle if unitary-proper-divisor-sum function f(x) = A063919(x) is iterated and the initial value is n. %H A097031 Antti Karttunen, <a href="/A097031/b097031.txt">Table of n, a(n) for n = 1..65537</a> %F A097031 a(n) = A318882(n) - A318883(n). - _Antti Karttunen_, Sep 22 2018 %e A097031 From _Antti Karttunen_, Sep 22 2018: (Start) %e A097031 For n = 1, A063919(1) = 1, that is, we immediately end with a terminal cycle of length 1 without a preceding transient part, thus a(1) = 1. %e A097031 For n = 2, A063919(2) = 1, and A063919(1) = 1, so we end with a terminal cycle of length 1 (after a transient part of length 1) thus a(2) = 1. %e A097031 For n = 30, A063919(30) = 42, A063919(42) = 54, A063919(54) = 30, thus a(30) = a(42) = a(54) = 3, as 30, 42 and 54 are all contained in their own terminal cycle of length 3, without a preceding transient part. (End) %e A097031 For n = 1506, the iteration-list is {1506, 1518, 1938, 2382, 2394, 2406, [2418, 2958, 3522, 3534, 4146, 4158, 3906, 3774, 4434, 4446, 3954, 3966, 3978, 3582, 2418, ..., ad infinitum]}. After a transient of length 6 the iteration ends in a cycle of length 14, thus a(1506) = 14. %t A097031 a063919[1] = 1; (* function a[] in A063919 by _Jean-François Alcover_ *) %t A097031 a063919[n_] := Total[Select[Divisors[n], GCD[#, n/#]==1&]]-n/;n>1 %t A097031 cycleLength[k_] := Module[{cycle=NestWhileList[a063919, k, UnsameQ, All]}, Apply[Subtract, Reverse[Flatten[Position[cycle, Last[cycle]], 1]]]] %t A097031 a097031[n_] := Map[cycleLength, Range[n]] %t A097031 a097031[105] (* _Hartmut F. W. Hoft_, Jan 24 2024 *) %o A097031 (PARI) %o A097031 A034460(n) = (sumdivmult(n, d, if(gcd(d, n/d)==1, d))-n); \\ From A034460 %o A097031 A063919(n) = if(1==n,n,A034460(n)); %o A097031 A097031(n) = { my(visited = Map()); for(j=1, oo, if(mapisdefined(visited, n), return(j-mapget(visited, n)), mapput(visited, n, j)); n = A063919(n)); }; %o A097031 \\ Or by using lists: %o A097031 pil(item,lista) = { for(i=1,#lista,if(lista[i]==item,return(i))); (0); }; %o A097031 A097031(n) = { my(visited = List([]), k); for(j=1, oo, if((k = pil(n,visited)) > 0, return(j-k)); listput(visited, n); n = A063919(n)); }; \\ _Antti Karttunen_, Sep 22 2018 %Y A097031 Cf. A002827, A063919, A063991, A097024, A097030, A097032, A097033, A097034, A097035, A097036, A097037, A318882, A318883. %K A097031 nonn %O A097031 1,30 %A A097031 _Labos Elemer_, Aug 30 2004