OFFSET
1,1
COMMENTS
Appeared in School Science and Mathematics in 1982.
LINKS
Enoch Haga, Problem, School Science and Mathematics, Nov 1983, vol. 83, no 7, page 628.
LaBar, Problem #3929, School Science and Mathematics, Dec 1982, vol. 82 no 8, page 715.
EXAMPLE
Beginning at n=1, algorithm produces s+t+a=8.
PROG
(This was in the formula section but is clearly a program in some language. - N. J. A. Sloane, Apr 18 2017)
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
(Python)
def a(n):
if n==1: return 8
l=[n]
while True:
if n%2==0: n//=2
else: n = 3*n + 1
l.append(n)
if n<2: break
return sum(l)
print([a(n) for n in range(1, 101)]) # Indranil Ghosh, Apr 14 2017
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
STATUS
approved