cp's OEIS Frontend

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.

A078719 Number of odd terms among n, f(n), f(f(n)), ...., 1 for the Collatz function (that is, until reaching "1" for the first time), or -1 if 1 is never reached.

This page as a plain text file.
%I A078719 #63 Feb 16 2025 08:32:48
%S A078719 1,1,3,1,2,3,6,1,7,2,5,3,3,6,6,1,4,7,7,2,2,5,5,3,8,3,42,6,6,6,40,1,9,
%T A078719 4,4,7,7,7,12,2,41,2,10,5,5,5,39,3,8,8,8,3,3,42,42,6,11,6,11,6,6,40,
%U A078719 40,1,9,9,9,4,4,4,38,7,43,7,4,7,7,12,12,2,7,41,41,2,2,10,10,5,10,5,34,5,5,39
%N A078719 Number of odd terms among n, f(n), f(f(n)), ...., 1 for the Collatz function (that is, until reaching "1" for the first time), or -1 if 1 is never reached.
%C A078719 The Collatz function (related to the "3x+1 problem") is defined by: f(n) = n/2 if n is even; f(n) = 3n + 1 if n is odd. A famous conjecture states that n, f(n), f(f(n)), .... eventually reaches 1.
%C A078719 a(n) = A006667(n) + 1; a(A000079(n))=1; a(A062052(n))=2; a(A062053(n))=3; a(A062054(n))=4; a(A062055(n))=5; a(A062056(n))=6; a(A062057(n))=7; a(A062058(n))=8; a(A062059(n))=9; a(A062060(n))=10. - _Reinhard Zumkeller_, Oct 08 2011
%C A078719 The count includes also the starting value n if it is odd. See A286380 for the version which never includes n itself. - _Antti Karttunen_, Aug 10 2017
%H A078719 Reinhard Zumkeller, <a href="/A078719/b078719.txt">Table of n, a(n) for n = 1..10000</a>
%H A078719 Chris K. Caldwell and G. L. Honaker, Jr., <a href="https://t5k.org/curios/page.php?curio_id=370">Prime curio for 41</a> (which says 41 is a fixed point)
%H A078719 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/CollatzProblem.html">Collatz Problem</a>
%H A078719 Wikipedia, <a href="http://en.wikipedia.org/wiki/Collatz_conjecture">Collatz conjecture</a>
%H A078719 <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a>
%F A078719 a(n) = A286380(n) + A000035(n). - _Antti Karttunen_, Aug 10 2017
%F A078719 a(n) = A258145(A003602(n)-1). - _Alan Michael Gómez Calderón_, Sep 15 2024
%e A078719 The terms n, f(n), f(f(n)), ...., 1 for n = 12 are: 12, 6, 3, 10, 5, 16, 8, 4, 2, 1, of which 3 are odd. Hence a(12) = 3.
%p A078719 a:= proc(n) option remember; `if`(n<2, 1,
%p A078719       `if`(n::even, a(n/2), 1+a(3*n+1)))
%p A078719     end:
%p A078719 seq(a(n), n=1..94);  # _Alois P. Heinz_, Jan 17 2025
%t A078719 f[n_] := Module[{a, i, o}, i = n; o = 1; a = {}; While[i > 1, If[Mod[i, 2] == 1, o = o + 1]; a = Append[a, i]; i = f[i]]; o]; Table[f[i], {i, 1, 100}]
%t A078719 Table[Count[NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &], _?OddQ], {n, 94}] (* _Jayanta Basu_, Jun 15 2013 *)
%o A078719 (Haskell)
%o A078719 a078719 =
%o A078719    (+ 1) . length . filter odd . takeWhile (> 2) . (iterate a006370)
%o A078719 a078719_list = map a078719 [1..]
%o A078719 -- _Reinhard Zumkeller_, Oct 08 2011
%o A078719 (PARI) a(n) = {my(x=n, v=List([])); while(x>1, if(x%2==0, x=x/2, listput(v, x); x=3*x+1)); 1+#v;} \\ _Jinyuan Wang_, Dec 29 2019
%Y A078719 Cf. A006370, A014682, A078720, A139391, A286380.
%Y A078719 Cf. A258145, A003602.
%K A078719 nonn
%O A078719 1,3
%A A078719 _Joseph L. Pe_, Dec 20 2002
%E A078719 "Escape clause" added to definition by _N. J. A. Sloane_, Jun 06 2017