about | help | code help+videos | done | prefs |
compound_savings
Write a function to count the number of years necessary to reach a savings goal, given initial principal and an interest rate. For example, with $100 of initial principal and a 10% annual interest rate, it would take eight years to reach $200. (After 1 year, we have $110; after two years, $110 + $11 = $121; after three years, $121 + $12.10 = $132.10; and so forth). compound_savings(100, 0.1, 200) → 8 compound_savings(100, 0.05, 200) → 15 compound_savings(100, 0.02, 200) → 36 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy