%I #31 Dec 23 2016 21:56:36
%S 1,2,3,6,4,31,7,55,4,33,5,30,32,1,4,19,8,112,56,16,27,4,4,26,2,20,223,
%T 102,34,14,6,162,2,9,10,75,31,113,21,100,33,20,2,23,30,57,5,28,24,30,
%U 224,269,20,295,11,85,103,140,9,71,113,55,34,110,76,49,57
%N Iterate the map k -> A087712(k) starting at n; a(n) is the number of steps at which we see a repeated term for the first time; or -1 if the trajectory never repeats.
%C The old entry with this A-number was a duplicate of A030298.
%C a(52) is currently unknown. - _Donovan Johnson_
%C a(52)-a(10000) were found using a conjunction of Mathematica and Kim Walisch's primecount program. The additional values of the prime-counting function can be found in the second a-file. - _Matthew House_, Dec 23 2016
%H Matthew House, <a href="/A098282/b098282.txt">Table of n, a(n) for n = 1..10000</a>
%H Farideh Firoozbakht, <a href="/A098282/a098282.txt">Notes on the missing terms in this sequence</a>
%H Matthew House, <a href="/A098282/a098282_1.txt">Values found using primecount</a>
%e 1 -> 1; 1 step to see a repeat, so a(1) = 1.
%e 2 -> 1 -> 1; 2 steps to see a repeat.
%e 3 -> 2 -> 1 -> 1; 3 steps to see a repeat.
%e 4 -> 11 -> 5 -> 3 -> 2 -> 1 -> 1; 6 steps to see a repeat.
%e 6 -> 12 -> 112 -> 11114 -> 1733 -> 270 -> 12223 -> 7128 -> 11122225 -> 33991010 -> 13913661 -> 2107998 -> 12222775 -> 33910130 -> 131212367 -> 56113213 -> 6837229 -> 4201627 -> 266366 -> 112430 -> 131359 -> 7981 -> 969 -> 278 -> 134 -> 119 -> 47 -> 15 -> 23 -> 9 -> 22 -> 15; 31 steps to see a repeat.
%e 9 -> 22 -> 15 -> 23 -> 9; 4 steps to see a repeat.
%e From _David Applegate_ and _N. J. A. Sloane_, Feb 09 2009: (Start)
%e The trajectories of the numbers 1 through 17, up to and including the first repeat, are as follows. Note that a(n) is one less than the number of terms shown.
%e [1, 1]
%e [2, 1, 1]
%e [3, 2, 1, 1]
%e [4, 11, 5, 3, 2, 1, 1]
%e [5, 3, 2, 1, 1]
%e [6, 12, 112, 11114, 1733, 270, 12223, 7128, 11122225, 33991010, 13913661, 2107998, 12222775, 33910130, 131212367, 56113213, 6837229, 4201627, 266366, 112430, 131359, 7981, 969, 278, 134, 119, 47, 15, 23, 9, 22, 15]
%e [7, 4, 11, 5, 3, 2, 1, 1]
%e [8, 111, 212, 1116, 112211, 52626, 124441, 28192, 11111152, 111165448, 1117261018, 1910112963, 252163429, 42205629, 2914219, 454002, 127605, 231542, 110938, 15631, 44510, 13605, 23155, 3582, 12246, 12637, 1509, 296, 11112, 111290, 131172, 1127117, 76613, 9470, 13161, 21328, 11111114, 14142115, 3625334, 1125035, 348169, 78151, 11369, 1373, 220, 1135, 349, 70, 134, 119, 47, 15, 23, 9, 22, 15]
%e [9, 22, 15, 23, 9]
%e [10, 13, 6, 12, 112, 11114, 1733, 270, 12223, 7128, 11122225, 33991010, 13913661, 2107998, 12222775, 33910130, 131212367, 56113213, 6837229, 4201627, 266366, 112430, 131359, 7981, 969, 278, 134, 119, 47, 15, 23, 9, 22, 15]
%e [11, 5, 3, 2, 1, 1]
%e [12, 112, 11114, 1733, 270, 12223, 7128, 11122225, 33991010, 13913661, 2107998, 12222775, 33910130, 131212367, 56113213, 6837229, 4201627, 266366, 112430, 131359, 7981, 969, 278, 134, 119, 47, 15, 23, 9, 22, 15]
%e [13, 6, 12, 112, 11114, 1733, 270, 12223, 7128, 11122225, 33991010, 13913661, 2107998, 12222775, 33910130, 131212367, 56113213, 6837229, 4201627, 266366, 112430, 131359, 7981, 969, 278, 134, 119, 47, 15, 23, 9, 22, 15]
%e [14, 14]
%e [15, 23, 9, 22, 15]
%e [16, 1111, 526, 156, 1126, 1103, 185, 312, 11126, 1734, 1277, 206, 127, 31, 11, 5, 3, 2, 1, 1]
%e [17, 7, 4, 11, 5, 3, 2, 1, 1]
%e For n = 18 see A077960.
%e (End)
%p with(numtheory):
%p f := proc(n) local t1, v, r, x, j;
%p if (n = 1) then return 1; end if;
%p t1 := ifactors(n): v := 0;
%p for x in op(2,t1) do r := pi(x[1]):
%p for j from 1 to x[2] do
%p v := v * 10^length(r) + r;
%p end do; end do; v; end proc;
%p t := proc(n) local v, l, s; v := n; s := {v}; l := [v]; v := f(v);
%p while not v in s do s := s union {v}; l := [op(l),v]; v := f(v); end do;
%p [op(l),v];
%p end proc; [seq(nops(t(n))-1, n=1..17)];
%p # _David Applegate_ and _N. J. A. Sloane_, Feb 09 2009
%t f[n_] := If[n==1,1,FromDigits@ Flatten[ IntegerDigits@# & /@ (PrimePi@#
%t & /@ Flatten[ Table[ First@#, {Last@#}] & /@ FactorInteger@n])]];
%t g[n_] := Length@ NestWhileList[f, n, UnsameQ, All] - 1; Array[g, 39]
%t (* _Robert G. Wilson v_, Feb 02 2009; modified slightly by _Farideh Firoozbakht_, Feb 10 2009 *)
%o (GBnums)
%o void ea (n)
%o {
%o mpz u[] ; // factors
%o mpz tr[]; // sequence
%o print(n);
%o while(n > 1)
%o {
%o lfactors(u,n); // factorize into u
%o vmap(u,pi); // replace factors by rank
%o n = catv(u); // concatenate
%o print(n);
%o if(vsearch(tr,n) > 0) break; // loop found
%o vpush(tr,n); // remember n
%o }
%o println('');
%o }
%o // _Jacques Tramu_
%o (Haskell)
%o import Data.List (genericIndex)
%o a098282 n = f [n] where
%o f xs = if y `elem` xs then length xs else f (y:xs) where
%o y = genericIndex (map a087712 [1..]) (head xs - 1)
%o -- _Reinhard Zumkeller_, Jul 14 2013
%Y Cf. A087712, A007097, A077960. See also A145077, A145078, A145079, A144760, A144813, A144814, A144915, A144914.
%Y See A156055 for another version.
%K nonn,base,nice
%O 1,2
%A _Eric Angelini_, Feb 02 2009
%E a(8) and a(10) found by _Jacques Tramu_
%E Extended through a(39) by _Robert G. Wilson v_, Feb 02 2009
%E Terms through a(39) corrected by _Farideh Firoozbakht_, Feb 10 2009
%E a(40)-a(51) from _Donovan Johnson_, Jan 08 2011
%E More terms from and a(40) corrected by _Matthew House_, Dec 23 2016