%I M0062 #54 Nov 04 2017 01:07:46
%S 0,1,1,2,1,1,1,2,3,3,1,6,1,4,4,5,1,3,1,6,2,5,1,4,2,6,2,1,1,14,1,2,5,7,
%T 2,3,1,6,2,3,1,13,1,4,6,7,1,5,3,2,3,8,1,12,2,4,2,3,1,10,1,8,2,3,2,11,
%U 1,4,3,5,1,8,1,4,4,4,2,10,1,6,4,5,1,5,2,8,6,6,1,9,3,5,3,3,3,8,1,2,3,4,1,17
%N "Length" of aliquot sequence for n.
%C The aliquot sequence for n is the trajectory of n under repeated application of the map x -> sigma(x) - x.
%C The trajectory will either have a transient part followed by a cyclic part, or will have an infinite transient part and never cycle.
%C Sequence gives (length of transient part of trajectory) - 1 (if trajectory ends at 1), or provided that it ends in cycle [e.g., (6) or (220 284)], gives (length of transient part of trajectory) + (length of cycle) = length of trajectory. - Corrected by _Antti Karttunen_, Nov 03 2017
%C See A098007 for a better version.
%C The function sigma = A000203 is defined only on the positive integers and not for 0, so the trajectory ends when 0 is reached. - _M. F. Hasler_, Nov 16 2013
%D G. Everest, A. van der Poorten, I. Shparlinski and T. Ward, Recurrence Sequences, Amer. Math. Soc., 2003; see esp. p. 255.
%D R. K. Guy, Unsolved Problems in Number Theory, B6.
%D R. K. Guy and J. L. Selfridge, Interim report on aliquot series, pp. 557-580 of Proceedings Manitoba Conference on Numerical Mathematics. University of Manitoba, Winnipeg, Oct 1971.
%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
%H Antti Karttunen, <a href="/A003023/b003023.txt">Table of n, a(n) for n = 1..275</a> (fate of 276 is unknown)
%H R. K. Guy and J. L. Selfridge, <a href="/A003023/a003023.pdf">Interim report on aliquot series</a>, pp. 557-580 of Proceedings Manitoba Conference on Numerical Mathematics. University of Manitoba, Winnipeg, Oct 1971. [Annotated scanned copy]
%H F. Richman, <a href="http://math.fau.edu/Richman/mla/aliquot.htm">Aliquot series: Abundant, deficient, perfect</a>
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/AliquotSequence.html">Aliquot Sequence</a>
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Aliquot_sequence">Aliquot sequence</a>
%e Examples of trajectories:
%e 1, 0, 0, ...
%e 2, 1, 0, 0, ...
%e 3, 1, 0, 0, ... (and similarly for any prime)
%e 4, 3, 1, 0, 0, ...
%e 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
%e 6, 6, 6, ... (and similarly for any perfect number)
%e 8, 7, 1, 0, 0, ...
%e 9, 4, 3, 1, 0, 0, ...
%e 12, 16, 15, 9, 4, 3, 1, 0, 0, ...
%e 14, 10, 8, 7, 1, 0, 0, ...
%e 25, 6, 6, 6, ...
%e 28, 28, 28, ... (the next perfect number)
%e 30, 42, 54, 66, 78, 90, 144, 259, 45, 33, 15, 9, 4, 3, 1, 0, 0, ...
%e 42, 54, 66, 78, 90, 144, 259, 45, 33, 15, 9, 4, 3, 1, 0, 0, ...
%p f:=proc(n) local t1, i,j,k; t1:=[n]; for i from 2 to 50 do j:= t1[i-1]; k:=sigma(j)-j; t1:=[op(t1), k]; od: t1; end; # produces trajectory for n
%t f[x_] := (k++; DivisorSigma[1, x] - x); f[1] = 1;
%t Table[k = 0; FixedPoint[f, n]; k, {n, 1, 102}]
%t (* _Jean-François Alcover_, Jul 27 2011 *)
%o (MuPAD) s := func(_plus(op(numlib::divisors(n)))-n,n): A003023 := proc(n) local i,T,m; begin m := n; i := 1; while T[ m ]<>1 and m<>1 do T[ m ] := 1; m := s(m); i := i+1 end_while; i-1 end_proc:
%o (Scheme)
%o (define (A003023 n) (let loop ((visited (list n)) (i 0)) (let ((next (A001065 (car visited)))) (cond ((zero? next) i) ((member next visited) (+ 1 i)) (else (loop (cons next visited) (+ 1 i)))))))
%o (define (A001065 n) (- (A000203 n) n)) ;; For an implementation of A000203, see under that entry.
%o ;; _Antti Karttunen_, Nov 03 2017
%Y Cf. A001065, A098007.
%Y Cf. A059447 (least k such that n is the length of the aliquot sequence for k ending at 1).
%K nonn,easy
%O 1,4
%A _N. J. A. Sloane_
%E More terms from _Matthew Conroy_, Jan 16 2006