let the amount given by grandma=x
As he spends half of his previous amount +1 in each store.
In first store, he spent x/2+1=(x+2)/2
money left with johnny after visiting first store x-((x+2)/2)=(x-2)/2
In 2nd store ,(x-2)/4+1=(x+2)/4
money left with him after visiting 2nd store=(x-2)/2-(x+2)/4=(x-6)/4
3rd store=(x-6)/8+1=(x+2)/8
left money after visiting 3rd store=(x-6)/4-(x+2)/8=(x-14)/8
in 4th store, (x-14)/16+1=(x+2)/16
money left after visiting 4th store=(x-14)/8-(x+2)/16=(x-30)/16
In 5th store, (x-30)/32+1=(x+2)/32
money left with him after visiting fifth store=(x-30)/16-(x+2)/32=(x-62)/32
He spent all his money so he left with zero amount after visiting all store=
At last he had money =0
(x-62)/32=0
x-62=0
x=62
so , grandma gave him=$62