We have n dollars to spend. Every day we buy either a candy for 1 dollar or an ice cream for 2 dollars. In how many ways can we spend the money

Respuesta :

Answer:

P(n) = P(n - 1) + P(n - 2) where P(1) = 1 and P(2) = 2, 1, 2, 3, 5, 8, 13, 21, 34, ...

Step-by-step explanation:

If we suppose that the order of which they are bought matters, then we either buy candy or an ice cream last. In other words, we have (n - 1) or (n - 2) left on previous days to spend.

Therefore,

P(n) = P(n - 1) + P(n - 2)

Where P(1) = 1 and P(2) = 2,

1, 2, 3, 5, 8, 13, 21, 34, ...