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.

User: Ryan Pythagoras Newton Critchlow

Ryan Pythagoras Newton Critchlow's wiki page.

Ryan Pythagoras Newton Critchlow has authored 2 sequences.

A288311 Number of steps, reduced mod n, to reach 1 in the Collatz 3x+1 problem, or -1 if 1 is never reached.

Original entry on oeis.org

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
Offset: 1

Author

Keywords

Examples

			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.
		

Crossrefs

Cf. A006577.

Programs

  • Mathematica
    Table[Mod[-1 + Length[NestWhileList[If[EvenQ@ #, #/2, 3 # + 1] &, n, # != 1 &]], n], {n, 72}] (* Michael De Vlieger, Jun 09 2017 *)
  • 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
  • Python
    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
    

Formula

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

A288023 Number of steps to reach 1 in the Collatz 3x+1 problem starting with the n-th triangular number, or -1 if 1 is never reached.

Original entry on oeis.org

0, 7, 8, 6, 17, 7, 18, 21, 16, 112, 27, 35, 92, 38, 20, 15, 36, 124, 106, 39, 127, 109, 16, 16, 24, 81, 107, 40, 27, 35, 110, 30, 43, 74, 38, 113, 170, 46, 121, 28, 103, 116, 36, 98, 124, 137, 18, 119, 132, 83, 26, 127, 26, 47, 34, 122, 91, 148, 117, 130, 37, 37, 112, 32, 76, 94, 58, 120, 120, 89, 133, 53, 115, 66
Offset: 1

Author

Keywords

Examples

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

Crossrefs

Programs

  • Mathematica
    Table[Length[NestWhileList[If[EvenQ[#],#/2,3#+1]&,n,#>1&]]-1,{n,Accumulate[ Range[80]]}] (* Harvey P. Dale, Aug 17 2017 *)
  • Python
    num = 1
    def triangleN(x):
        return x*(x+1)/2
    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
    while True:
        print(stepCount(triangleN(num)))
        num += 1

Formula

a(n) = A006577(A000217(n)). - Omar E. Pol, Jun 04 2017