The Golden Ratio

July 10, 2009

I was helping my daughter with her math homework recently, and came across this problem in continued fractions:

1 + \frac 1 { 1 + \frac 1 { 1 + \frac 1 { 1 + \frac 1 { 1 + \frac 1 \ldots } } } }

This fraction can be considered as a sequence of terms

G_0 = 1

G_1 = 1 + { 1 \over 1 } = 2

G_2 = 1 + { 1 \over 1 + { 1 \over 1 } } = { 3 \over 2 }

G_3 = 1 + { 1 \over 1 + { 1 \over 1 + { 1 \over 1 } } } = { 5 \over 3 }

Or, in general

G_{n+1} = 1 + \frac 1 { G_n }

The first ten elements of the sequence are 1, 2, 3/2, 5/3, 8/5, 13/8, 21/13, 34/21, 55/34, and 89/55.

Your task is to write a program that evaluates the nth element of the sequence. What is the value of G_{200}? When you are finished, you may read or run a suggested solution, or post your own solution or discuss the exercise in the comments below.

Advertisement

Pages: 1 2