This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A036840 #20 Dec 06 2017 20:07:33 %S A036840 1,1,3,3,7,3,7,7,7,7,7,7,20,7,12,12,39,7,39,12,20,7,20,12,20,20,39,20, %T A036840 39,12,39,39,20,39,39,20,154,39,39,39,39,20,154,20,39,20,39,39,154,20, %U A036840 154,39,154,39,39,39,154,39,39,39,100,39,154,154,100,20,100,154,39,39 %N A036840 a(n) is the average of the repeating terms of {T(n,k)} rounded to the nearest integer (rounding up if there's a choice), if {T(n,k)} is eventually periodic; = 0 otherwise. Here T(n,k) is the "phi/sigma tug-of-war sequence with seed n" defined by T(n,1) = phi(n), T(n,2) = sigma(phi(n)), T(n,3) = phi(sigma(phi(n))), ..., T(n,k) = phi(T(n,k-1)) if k is odd and = sigma(T(n,k-1)) if k is even. %C A036840 Conjecture: a(n) is never 0; i.e. the sequence {T(n,k)} is eventually periodic for every n. %C A036840 a(n) - n can be thought of as the final score in the phi/sigma tug-of-war with seed n. For example a(5) - 5 = 7 - 5 = 2, so sigma wins by "2 points" over phi at 5. a(8) - 8 = 7 - 8 = -1, so phi wins by "1 point" over sigma at 8. a(3) - 3 = 3 - 3 = 0, so it is a tie at 3. Are sigma's margins of victory over phi bounded? Are phi's bounded? %H A036840 Antti Karttunen, <a href="/A036840/b036840.txt">Table of n, a(n) for n = 1..16384</a> %e A036840 The sequence {T(5,k)} is 4, 7, 6, 12, 4, 7, .... The average of the repeating numbers is 7.25 which rounds off to 7. So a(5) = 7. The sequence {T(37,k)} is 36, 91, 72, 195, 96, 252, 72, 195, .... The average of the repeating numbers is 153.75, which rounds off to 154. So a(37) = 154. %t A036840 a[ n_ ] := Module[ {}, For[ m=n; seq={}, !MemberQ[ seq, m ], m=DivisorSigma[ 1, EulerPhi[ m ] ], AppendTo[ seq, m ] ]; rp=Drop[ seq, Position[ seq, m ][ [ 1, 1 ] ]-1 ]; Floor[ 1/2+(Plus@@Join[ rp, EulerPhi/@rp ])/2/Length[ rp ] ] ] %o A036840 (Scheme) (define (A036840 n) (let loop ((visited (list n)) (i 1)) (let ((next ((if (odd? i) A000010 A000203) (car visited)))) (cond ((member next (reverse visited)) => (lambda (start_of_cyclic_part) (cond ((even? (length start_of_cyclic_part)) (floor->exact (+ 1/2 (/ (apply + start_of_cyclic_part) (length start_of_cyclic_part))))) (else (loop (cons next visited) (+ 1 i)))))) (else (loop (cons next visited) (+ 1 i))))))) ;; _Antti Karttunen_, Dec 06 2017 %Y A036840 Cf. A000010, A000203, A036845, A066437, A095955, A096993. %K A036840 nonn %O A036840 1,3 %A A036840 _Joseph L. Pe_, Jan 09 2002 %E A036840 Edited by _Dean Hickerson_, Jan 18 2002