OFFSET
1,10
COMMENTS
This sequence implements the original definition given for A097033.
LINKS
Antti Karttunen, Table of n, a(n) for n = 1..87360
EXAMPLE
For n = 1, A063919(1) = 1, that is, we immediately end with a terminal cycle (of length 1 in this case), thus there are no transient part, and a(1) = 0.
For n = 2, A063919(2) = 1, and A063919(1) = 1, so we end with a terminal cycle after a transient part of length 1, thus a(2) = 1.
For n = 30, A063919(30) = 42, A063919(42) = 54, A063919(54) = 30, thus a(30) = a(42) = a(54) = 0, as 30, 42 and 54 are all contained in their own terminal cycle, without a preceding transient part.
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) = 6.
MATHEMATICA
a063919[1] = 1; (* function a[] in A063919 by Jean-François Alcover *)
a063919[n_] := Total[Select[Divisors[n], GCD[#, n/#]==1&]]-n/; n>1
transient[k_] := Module[{iter=NestWhileList[a063919, k, UnsameQ, All]}, Position[iter, Last[iter]][[1, 1]]]-1
a318883[n_] := Map[transient, Range[n]]
a318883[105] (* Hartmut F. W. Hoft, Jan 25 2024 *)
PROG
CROSSREFS
KEYWORD
nonn
AUTHOR
STATUS
approved