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.

A181717 Fibonacci-Collatz sequence: a(1)=0, a(2)=1; for n>2, let fib=a(n-1)+a(n-2); if fib is odd then a(n)=3*fib+1 else a(n)=fib/2.

Original entry on oeis.org

0, 1, 4, 16, 10, 13, 70, 250, 160, 205, 1096, 3904, 2500, 3202, 2851, 18160, 63034, 40597, 310894, 1054474, 682684, 868579, 4653790, 16567108, 10610449, 81532672, 276429364, 178981018, 227705191, 1220058628, 4343291458, 2781675043, 21374899504, 72469723642
Offset: 1

Views

Author

Ralf Stephan, Nov 17 2010

Keywords

Comments

It is easy to prove that all the terms a(n) with n>=7 are congruent to 7 mod 9. Conjecture: for every k>0 there is an index m such that all the a(n) with n>m have the same residue mod 3^k. - Giovanni Resta, Nov 17 2010

Crossrefs

Programs

  • Haskell
    a181717 n = a181717_list !! (n-1)
    a181717_list = 0 : 1 : fc 1 0 where
       fc x x' = y : fc y x where y = a006370 (x + x')
    -- Reinhard Zumkeller, Oct 09 2011
    
  • Maple
    a:= proc(n) option remember; local f;
          if n<3 then return n-1 fi;
          f:= a(n-1) +a(n-2);
          `if`(irem(f, 2)=0, f/2, 3*f+1)
        end:
    seq(a(n), n=1..50); # Alois P. Heinz, Oct 09 2011
  • Mathematica
    nxt[{a_,b_}]:=Module[{fib=a+b},If[OddQ[fib],{b,3fib+1},{b,fib/2}]]; Transpose[NestList[nxt,{0,1},40]][[1]] (* Harvey P. Dale, Mar 21 2012 *)
  • PARI
    v=vector(60,n,0); v[2]=1; for(n=3,60,f=v[n-1]+v[n-2]; v[n]=if(f%2,3*f+1,f/2))
    
  • SageMath
    @CachedFunction
    def a(n):
        if n<3: return n-1
        elif (a(n-1)+a(n-2))%2==1: return 3*(a(n-1)+a(n-2))+1
        else: return (a(n-1)+a(n-2))/2
    [a(n) for n in range(1,51)] # G. C. Greubel, Mar 25 2024