50.8k views
4 votes
A store had 150 laptops in the month of January. Every month, 20% of the laptops were sold and 10 new laptops were stocked in the store. Write a recursive function that represents the number of laptops in the store f(n) after n months.

User Roskelld
by
7.2k points

2 Answers

5 votes
the answer is f(n) = 0.8 × f(n − 1) + 10, f(0) = 150, n > 0

User Writofmandamus
by
7.8k points
1 vote

Answer:

f(n) = 0.8 x f(n − 1) + 10, f(0) = 150, n > 0

Explanation:

Here, n represents the number of months and f(n) represents the number of laptops after n months,

Since, initially there are 150 laptops,

That is, f(0) = 150,

Also, every month, 20% of the laptops were sold and 10 new laptops were stocked in the store,

⇒ f(1) = (100-20)% of 150 + 10 = 80% of 150 + 10 = 0.8 × (150) + 10 = 0.8×(f(0)) - 1

Similarly,

f(2) = 0.8 × ( f(1) ) + 10

f(3) = 0.8 × ( f(2) ) + 10

f(4) = 0.8 × ( f(3) ) + 10

..........., so on...............

Hence, we can write,

f(n) = 0.8 × ( f(n-1) ) + 10

Also, n ( number of months ) can not be negative or zero,

⇒ n > 0,

Therefore, the required recursive function that represents the number of laptops in the store f(n) after n months is,

f(n) = 0.8 x f(n − 1) + 10, f(0) = 150, n > 0

User Cojack
by
7.0k points