OFFSET
0,3
COMMENTS
The iterations always fall to zero, proof by induction: 0 is 0; 1 -> 0; 2 -> 1; 3 -> 2; 4 -> 2; n -> some number less than n.
First occurrence of k >= 0: 0, 1, 2, 3, 10, 11, 26, 83, 178, ... see A324921.
FORMULA
a(n) = 1 iff n is a perfect square (A000290).
EXAMPLE
a(0) = 0;
a(1) = 1 since 1 -> 0;
a(2) = 2 since 2 -> 1 -> 0;
a(3) = 3 since 3 -> 2 -> 1 -> 0;
a(4) = 1 since 4 -> 0; etc.
MATHEMATICA
g[n_] := Block[{d = Divisors@n}, len = Length@d; If[ OddQ@ len, 0, d[[1 + len/2]] - d[[len/2]]]]; f[n_] := Length@ NestWhileList[f, n, # > 0 &] -1; Array[f, 105, 0]
PROG
(PARI) a056737(n)=n=divisors(n); n[(2+#n)\2]-n[(1+#n)\2] \\ after M. F. Hasler in A056737
a(n) = my(x=n, i=0); while(x!=0, i++; x=a056737(x)); i \\ Felix Fröhlich, Mar 20 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Robert G. Wilson v, Mar 20 2019
STATUS
approved