Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use Haskell coding language to resolve 3. compoundInterest Task: Compute the compound interest earned. compoundinterest::Floatingaaprincipala-rateInt-numofcompoundingperiods Compound interest is the interest earned from some quantity over
Use Haskell coding language to resolve
3. compoundInterest Task: Compute the compound interest earned. compoundinterest::Floatingaaprincipala-rateInt-numofcompoundingperiods Compound interest is the interest earned from some quantity over multiple "compounding periods", where for each period the amount of interest is based on the original quantity (the principal) and on accumulated interest from all previous periods. E.g.r given a principal of 100 and a rate of 20%, the first period earns us 1000.2=20. In the second period we earn (100+20)0.2=24, for a total accumulated interest of 20+24=44. In the third period we earn (100+44)0.2=28.8, for a total accumulated interest of 44+28.8=72.8 While there are formulae that will let you directly compute the amount of compound interest given the other parameters, we strongly encourage you to implement this function using recursion -- it's good practice! Examples: 4. collatzLen Task: Compute the length of the Collatz sequence starting at the input. collatzLen::IntegerstartvalueofthesequenceInteger The Collatz conjecture has to do with the sequence starting with any positive integer n, where each subsequent term in the sequence is defined by applying the function C to the preceding term, where: C(n)={n/23n+1ifnisevenifnisodd The conjecture states that all Collatz sequences eventually end in 1. E.g., if we start with n=10, we step through the subsequent values 5,16,8,4,2,1. Your function will return the number of steps in the Collatz sequence between a starting value of n and the terminating 1 . ExamplesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started