%I #24 May 08 2021 23:04:44
%S 8,3,49,7,36,55,288,15,339,46,259,67,119,302,694,31,214,357,519,66,
%T 148,281,633,91,658,145,101440,330,442,724,101104,63,841,248,540,393,
%U 535,557,2344,106,101331,190,1338,325,497,679,100979,139,806,708,1130,197
%N Ulam's conjecture (steps to return n to 1 after division by 2 and, if needed, multiplication by 3 with 1 added).
%C Appeared in School Science and Mathematics in 1982.
%H Enoch Haga, <a href="https://doi.org/10.1111/j.1949-8594.1983.tb10148.x">Problem</a>, School Science and Mathematics, Nov 1983, vol. 83, no 7, page 628.
%H LaBar, <a href="https://doi.org/10.1111/j.1949-8594.1982.tb10084.x">Problem #3929</a>, School Science and Mathematics, Dec 1982, vol. 82 no 8, page 715.
%e Beginning at n=1, algorithm produces s+t+a=8.
%o (This was in the formula section but is clearly a program in some language. - _N. J. A. Sloane_, Apr 18 2017)
%o n=n+1:a=n\x=n/2\if int(x)=x then e=e+1:n=x:s=s+n: if n=1 then print s+t+a:e=0:o=0:s=0:t=0:n=a:return to n=n+1\if int(x)<>x then o=o+1:y=n*3+1:n=y:t=t+n: if n=1 then print s+t+a:e=0:o=0:s=0:t=0:n=a:return to n=n+1:else return to x=n/2
%o (Python)
%o def a(n):
%o if n==1: return 8
%o l=[n]
%o while True:
%o if n%2==0: n//=2
%o else: n = 3*n + 1
%o l.append(n)
%o if n<2: break
%o return sum(l)
%o print([a(n) for n in range(1, 101)]) # _Indranil Ghosh_, Apr 14 2017
%Y Almost the same as A033493.
%Y Cf. A049067.
%K easy,nonn
%O 1,1
%A _Enoch Haga_
|