We have n dollars to spend Every day we buy either a candy f
Solution
Lets say Ice cream cost = 2$, Candy cost is =1$,
Lets assume some value of n
n= 2 ....2I+1C=2, we can buy 2 candy or 1 Ice cream......................2 ways
n=3......2I+1C=3, we can buy 3 Candy or 1 candy and 1 Ice cream...2 ways
n=8...2I+1c=8, we can buy
8Candy (or) 6 candy,1 Ice cream (or)4 candy,2 ice cream (or) 2 candy ,3 ice cream (or) 4 ice cream...5 ways
So we can generalise this as follows.
Ice cream co-efficient is 2 and Candy co-efficeint is 1, LCM of these two numbers is 2..
So total no of ways = Integer(n/LCM)+1 = Integer(n/2)+1
We need write the integer part when n/2 is fraction
e.g. If n=7 ... Answer will be = Integer(7/2)+1 = Integer(3.5)+1 = 3+1= 4 ways..
7 candy or 5 candy&1 ice cream (or) 3 candy & 2 ice cream (or) 1 candy & 3 ice cream
