using a recursive function to repeat input
(counter version)