Added recursive counter, getting program ready for a parallelized solution