OFFSET
1,1
COMMENTS
LINKS
T. D. Noe, Table of n, a(n) for n = 1..1009
FORMULA
Numbers of the form (2^m*(2^n-1)/3-1)/3 where n == 2 (mod 6) if m is even and n == 4 (mod 5) if m is odd. - Charles R Greathouse IV, Sep 09 2022
EXAMPLE
The Collatz iteration of 113 is 113, 340, 170, 85, 256, 128, 64, 32, 16, 8, 4, 2, 1, which shows that 113, 85, and 1 are the three odd terms.
MATHEMATICA
Collatz[n_] := NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &]; t = {}; Do[If[Length[Select[Collatz[n], OddQ]] == 3, AppendTo[t, n]], {n, 1, 10000, 2}]; t
PROG
(Python)
# get n-th term in sequence
def isqrt(n):
i=0
while(i*i<=n):
i+=1
return i-1
for n in range (200):
s = isqrt(3*n)//3
a = s*3
b = (a*a)//3
c = n-b
d = 4*(n*3+a+(c<s)+(c>4*s+1)+(c>5*s+1))+5
e = isqrt(d)
f = e-1-( (d-e*e) >> 1 )
r = ((((8<<e)-(1<<f))//3)-1)//3
print(r, end =", ") # André Hallqvist, Jul 25 2019
(Python)
# just prints the sequence
for a in range (5, 100, 1):
for b in range(a-8+4*(a&1), 0, -6):
print(( ((1<<a)-(1<<b))//3-1)//3 , end=", ") # André Hallqvist, Aug 14 2019
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
T. D. Noe, Oct 28 2011
STATUS
approved