Discussion: More Math, but Fun This Time
Explore the concept of the golden ratio and learn how to implement its calculation using recursive functions in C. This lesson helps you grasp recursion and mathematical expressions as applied in programming puzzles.
We'll cover the following...
Run the code
Now, it's time to execute the code and observe the output.
Understanding the output
The code outputs the following line:
Phi is 1.618034
This is the golden ratio, represented by Greek letter phi,
Golden ratio
The golden ratio is yet another of those mathematical joys that, like the Fibonacci sequence, appear frequently in nature. It’s important enough to have its own Greek letter assigned, phi or
Phi
Phi is a concept that’s best illustrated as opposed to being explained in text. The diagram below illustrates how the ratio applies to two lengths, A and B.
In this diagram,