login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A288311 Number of steps, reduced mod n, to reach 1 in the Collatz 3x+1 problem, or -1 if 1 is never reached. 0
0, 1, 1, 2, 0, 2, 2, 3, 1, 6, 3, 9, 9, 3, 2, 4, 12, 2, 1, 7, 7, 15, 15, 10, 23, 10, 3, 18, 18, 18, 13, 5, 26, 13, 13, 21, 21, 21, 34, 8, 27, 8, 29, 16, 16, 16, 10, 11, 24, 24, 24, 11, 11, 4, 2, 19, 32, 19, 32, 19, 19, 45, 44, 6, 27, 27, 27, 14, 14, 14, 31, 22 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,4

LINKS

Table of n, a(n) for n=1..72.

FORMULA

a(n) = A006577(n) mod n.

EXAMPLE

For n = 3, which takes 7 steps to reach 1 in the Collatz (3x+1) problem: (10, 5, 16, 8, 4, 2, 1), 7 mod 3 = 1.

MATHEMATICA

Table[Mod[-1 + Length[NestWhileList[If[EvenQ@ #, #/2, 3 # + 1] &, n, # != 1 &]], n], {n, 72}] (* Michael De Vlieger, Jun 09 2017 *)

PROG

(Python 3)

def stepCount(x):

    x = int(x)

    steps = 0

    while True:

        if x == 1:

            break

        elif x % 2 == 0:

            x = x/2

            steps += 1

        else:

            x = x*3 + 1

            steps += 1

    return steps

n = 1

while True:

    print(stepCount(n) % n)

    n += 1

(PARI) a(n)=s=n; c=0; while(s>1, s=if(s%2, 3*s+1, s/2); c++); c % n; \\ Michel Marcus, Jun 10 2017

CROSSREFS

Cf. A006577.

Sequence in context: A293665 A159632 A164733 * A244366 A262676 A070101

Adjacent sequences:  A288308 A288309 A288310 * A288312 A288313 A288314

KEYWORD

nonn

AUTHOR

Ryan Pythagoras Newton Critchlow, Jun 07 2017

STATUS

approved

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified July 14 16:21 EDT 2020. Contains 335729 sequences. (Running on oeis4.)