Working code for finding and printing prime numbers