n=20, k=3 :
First Peter can smoke 20 times and leaving 20 butts.
Now he can make 1 new smoke by using 3 butts:
New smoke = 20/3 = 6
Butts left = 20%6 = 2
Now Peter can smoke 6 more times, thus he has smoked 26 times
leaving 6 more butts, making the total butts 6+2=8.
New smoke = 8/3 = 2
Butts left = 8%3 = 2
Peter can smoke twice, has smoked 26+2 = 28 times and leaving
two more butts (current butts = 2+2 = 4).
New smoke = 4/3 = 1
Butts left = 4%3 = 1
Peter smoke once more and he has smoked for 29 times and
leaving 1+1 = 2 butts.
Since he needs 3 butts to make a new smoke, yet only two available
then Peter can't make anymore smoke.
So Peter smoked 29 times.
Hope this simulation helps!!

There are 3 things one need to be successful : motivation, ability and chance. And if you're a believer, make it four : God's will.