login
a(n) is the least number that enters a cycle of length 2n in the iteration sequence s(0)=n, s(k+1) = s(k) + (-1)^k*d(s(k)), where d(n) is the number of divisors of n (A000005).
1

%I #17 Jun 06 2017 10:24:57

%S 3,93,273,1617,684,3993,58695,91355,572793,167055,441519,13991016,

%T 2337513,20225991,48163788,20625997,148789675,470944675,626064036,

%U 506112555,963071088,494359089,3252701700,3972446520,4515893681,3472027000,9096968436

%N a(n) is the least number that enters a cycle of length 2n in the iteration sequence s(0)=n, s(k+1) = s(k) + (-1)^k*d(s(k)), where d(n) is the number of divisors of n (A000005).

%H Claudia Spiro, <a href="http://matwbn.icm.edu.pl/ksiazki/aa/aa46/aa4633.pdf">An Iteration Problem Involving the Divisor Function</a>, Acta Arithmetica, Vol. 46, No. 3 (1986), pp. 215-225.

%t nmax=10;lst=ConstantArray[0,nmax];For[n=2, n<10^6, n++; c=1; v={}; m=0; s=1; a=n; i={}; While[m<10^6, AppendTo[v, a]; If[Length[v] > 3, i=LongestCommonSubsequencePositions[v[[1;; -3]], v[[-2;; -1]]], i = {}];

%t If[Length[i]==2 && Differences[i[[1]]][[1]]==1, c=Length[v]-i[[1]][[1]]-1; Break[]]; m++; a = a + s*DivisorSigma[0, a]; s = -s; ]; If[c/2<nmax && lst[[c/2]] == 0, lst[[c/2]]=n]]; lst (* _Amiram Eldar_, Jun 05 2017 *)

%o (PARI) findpos(v, new) = {for(i=1, #v, if (v[#v-i+1] == new, return (i)););}

%o loop(n) = {my(k = 1, ok = 0, v = []); while(!ok, new = n + k*numdiv(n); if (pos = findpos (v, new), if (#v > pos, if (v[#v] == v[#v - pos], return (pos)););); n = new; k = -k; v = concat(v, new););}

%o a(n) = my(k=3); while (loop(k) != 2*n, k++); k;

%Y Cf. A000005, A049820, A062249, A175304 (numbers with cycle of length 2), A285004 (records of this sequence).

%K nonn,more

%O 1,1

%A _Michel Marcus_, Jun 05 2017

%E a(19)-a(27) from _Giovanni Resta_, Jun 06 2017