Two quantities a and b are said to be in the golden ratio if (a+b)ais equal to ab. Assuming a and b are line segments, the golden section is a line segment divided according to the golden ratio: The total length (a + b) is to the longer segment a as a is to the shorter segment b. It turns out that the ratios of successive terms of the Fibonacci sequence approximate the golden ratio. That is to say F(n+1)F(n) is, in the limit, the golden ratio, where F(n) is the nth number of the Fibonacci sequence. Consider the function below that computes an approximation to the golden ratio using the (n-1) and (n-2) numbers in the Fibonacci sequence: double golden(int n) { } double ratio; if (n <= 2) { ratio = 1.0; } else { ratio = ((1.0) * fib(n-1)) / (1.0 * fib(n - 2)); } return ratio; Which statements are true? 1.The function golden is recursive II.The function goldenis a helper function III.The function goldenassumes that another function fib computes the Fibonacci numbers required to compute the ratio
Two quantities a and b are said to be in the golden ratio if (a+b)ais equal to ab. Assuming a and b are line segments, the golden section is a line segment divided according to the golden ratio: The total length (a + b) is to the longer segment a as a is to the shorter segment b. It turns out that the ratios of successive terms of the Fibonacci sequence approximate the golden ratio. That is to say F(n+1)F(n) is, in the limit, the golden ratio, where F(n) is the nth number of the Fibonacci sequence. Consider the function below that computes an approximation to the golden ratio using the (n-1) and (n-2) numbers in the Fibonacci sequence: double golden(int n) { } double ratio; if (n <= 2) { ratio = 1.0; } else { ratio = ((1.0) * fib(n-1)) / (1.0 * fib(n - 2)); } return ratio; Which statements are true? 1.The function golden is recursive II.The function goldenis a helper function III.The function goldenassumes that another function fib computes the Fibonacci numbers required to compute the ratio
Related questions
Question
C++
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps