about | help | code help+videos | done | prefs |
The "golden ratio" can be calculated using a recursive formula. If we define g as the golden ratio, we note that g=1+1/g. Using this formula recursively, we can theoretically calculate g to any degree of accuracy. Write a method that returns the result of howMany recursive steps into this recursive formula. For example: goldenRatio(2) returns 1.5 because 1+1/(1+1/(1)) is 1.5. If howMany=0, just return 1. goldenRatio(0) → 1.0 goldenRatio(1) → 2.0 goldenRatio(2) → 1.5 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 380
Copyright Nick Parlante 2017 - privacy