login
A008877
3x+1 sequence starting at 57.
4
57, 172, 86, 43, 130, 65, 196, 98, 49, 148, 74, 37, 112, 56, 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1
OFFSET
0,1
REFERENCES
R. K. Guy, Unsolved Problems in Number Theory, E16.
FORMULA
G.f.: (57 + 172*x + 86*x^2 - 14*x^3 - 42*x^4 - 21*x^5 + 153*x^6 - 32*x^7 - 16*x^8 - 48*x^9 - 24*x^10 - 12*x^11 - 36*x^12 - 18*x^13 - 9*x^14 - 98*x^15 - 49*x^16 - 6*x^17 - 3*x^18 + 27*x^19 - 5*x^20 + 41*x^21 - 8*x^22 - 4*x^23 - 12*x^24 - 6*x^25 - 3*x^26 - 35*x^27 - 4*x^28 - 2*x^29 - x^30 - 14*x^31 - 7*x^32)/(1 - x^3). - Charles R Greathouse IV, May 25 2026
MAPLE
f := proc(n) option remember; if n = 0 then 57; elif f(n-1) mod 2 = 0 then f(n-1)/2 else 3*f(n-1)+1; fi; end;
MATHEMATICA
NestList[If[EvenQ[#], #/2, 3# + 1]&, 57, 100] (* Vincenzo Librandi, Jul 29 2014 *)
PROG
(Haskell)
a008877 n = a008877_list !! n
a008877_list = 57 : iterate a006370 57
-- Reinhard Zumkeller, Aug 30 2012
(Magma) [n eq 1 select 57 else IsOdd(Self(n-1)) select 3*Self(n-1)+1 else Self(n-1) div 2: n in [1..80]]; // Vincenzo Librandi, Jul 29 2014
(PARI) a(n)=if(n>29, [4, 2, 1][n%3+1], [57, 172, 86, 43, 130, 65, 196, 98, 49, 148, 74, 37, 112, 56, 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8][n+1]) \\ Charles R Greathouse IV, May 25 2026
CROSSREFS
Cf. A006370.
Row 57 of A347270.
Sequence in context: A044389 A044770 A389180 * A381766 A338078 A376538
KEYWORD
nonn,easy
STATUS
approved