The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A237660 Consider the Collatz trajectory of n; if all terms except n and 1 are even then a(n) = 0, otherwise a(n) is the last odd number before 1. 3
0, 0, 5, 0, 0, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 21, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 85, 5, 5, 5, 5, 5, 5, 5, 5, 21, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 85 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,3
COMMENTS
Records (A002450) and indices of records (A237661) are as following:
Records: 5, 21, 85, 341, 1365, 5461, 21845, ...
Indices: 3, 42, 75, 151, 2730, 7281, 14563, ...
See A238192 and A238193 for a slightly different version. - T. D. Noe, Feb 21 2014
Differs from A238192 at n = 5, 21, 85, 341, 1365, 5461, 21845, ... (A002450 without its two initial terms). - Antti Karttunen, Aug 13 2017
LINKS
Kival Ngaokrajang, Illustration for n = 1..20
MATHEMATICA
{0}~Join~Table[If[AllTrue[#, EvenQ], 0, SelectFirst[Reverse@ #, OddQ]] &@ Most@ Rest@ NestWhileList[If[EvenQ@ #, #/2, (3 # + 1)/2] &, n, # > 1 &], {n, 2, 113}] (* Michael De Vlieger, Aug 14 2017 *)
PROG
(Small Basic)
For nn = 1 To 200
n = nn
c1 = 0
c2 = 0
loop:
m2 = math.Remainder(n, 2)
If m2 = 0 Then
n = n/2
c2 = c2 + 1
Else
n = n*3 + 1
c2 = 0
EndIf
a[c1] = n
c1 = c1 + 1
If n = 1 Then
If a[c1-c2-2] = "" then
a[c1-c2-2] = 0
EndIf
TextWindow.Write(a[c1-c2-2]+", ")
Goto stop
Else
Goto loop
EndIf
stop:
EndFor
(Scheme)
(define (A237660 n) (let loop ((n (A014682 n)) (last-odd 0)) (if (= 1 n) last-odd (loop (A014682 n) (if (odd? n) n last-odd)))))
(define (A014682 n) (if (even? n) (/ n 2) (/ (+ n n n 1) 2)))
;; Antti Karttunen, Aug 13 2017
(PARI) a(n)=my(k); if(n%2, n=3*n+1); n>>=valuation(n, 2); if(n==1, return(0)); k=n; while(1, n+=(n+1)>>1; n>>=valuation(n, 2); if(n==1, return(k), k=n)) \\ Charles R Greathouse IV, Aug 14 2017
CROSSREFS
Sequence in context: A073231 A099223 A233427 * A261852 A254293 A263496
KEYWORD
nonn
AUTHOR
Kival Ngaokrajang, Feb 11 2014
EXTENSIONS
Edited by N. J. A. Sloane, Feb 20 2014
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified June 5 11:59 EDT 2024. Contains 373105 sequences. (Running on oeis4.)