A088696 Triangle read by rows, giving number of partial quotients in continued fraction representation of terms in the left branch of the infinite Stern-Brocot tree.
1, 1, 2, 1, 2, 3, 2, 1, 2, 3, 2, 3, 4, 3, 2, 1, 2, 3, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 4, 3, 2, 1, 2, 3, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 4, 3, 2, 3, 4, 5, 4, 5, 6, 5, 4, 3, 4, 5, 4, 3, 4, 3, 2, 1, 2, 3, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 4, 3, 2, 3, 4, 5, 4, 5, 6, 5, 4, 3, 4, 5, 4, 3, 4, 3, 2, 3, 4, 5, 4, 5, 6, 5, 4, 5, 6
Offset: 1
Examples
Fractions in the left branch of the infinite Stern-Brocot tree (the fractions between 0 and 1), are: 1/2; 1/3, 2/3; 1/4, 2/5, 3/5, 3/4; 1/5, 2/7, 3/8, 3/7, 4/7, 5/8, 5/7, 4/5; ... and their corresponding continued fraction representations are: [2] [3] [1,2] [4] [2,2] [1,1,2] [1,3] [5] [3,2] [2,1,2] [2,3] [1,1,3] [1,1,1,2] [1,2,2] [1,4] ... with the number of terms in each continued fraction representation generating the present triangle: 1 1 2 1 2 3 2 1 2 3 2 3 4 3 2 ...
References
- R. L. Graham, D. E. Knuth and O. Patashnik, Concrete Mathematics. Addison-Wesley, Reading, MA, 1990, pp. 116-117.
Links
- Andrey Zabolotskiy, Table of n, a(n) for n = 1..8191
Programs
-
Haskell
a088696 n = a088696_list !! (n-1) a088696_list = f [1] where f (x:xs) = x : f (xs ++ [x + 1 - x `mod` 2, x + x `mod` 2]) -- Reinhard Zumkeller, Mar 07 2011
-
Mathematica
sb[n_List] := Block[{k = l = Length[n], a = n}, While[k > 1, a = Insert[ a, (Numerator[ a[[k]]] + Numerator[ a[[k - 1]]]) / (Denominator[ a[[k]]] + Denominator[ a[[k - 1]]]), k]; k-- ]; a]; sbn[n_] := Complement[ Nest[ sb, {0, 1}, n], Nest[ sb, {0, 1}, n - 1]]; f[n_] := Length /@ (ContinuedFraction /@ sbn[n]) - 1; Flatten[ Table[ f[n], {n, 7}]] (* Robert G. Wilson v, Jun 09 2004 *) Flatten[NestList[Join[#, Reverse[#] + 1] &, {1}, 7]]; (* from A164738, Jon Maiga, Sep 26 2019 *)
-
Python
a = [[1]] for n in range(6): a.append(a[-1] + [x+1 for x in a[-1][::-1]]) print(sum(a, [])) # Andrey Zabolotskiy, Mar 27 2020, after Jon Maiga
Extensions
Edited and extended by Robert G. Wilson v, Jun 09 2004
Comments