If I've understood your question correctly, and assuming you're using java
if (check != 1) {
System.out.println(counter);
}
If it's c or c++ you'd import STDIO at the tope of your file and do:
if ($check != 1) {
printf("%d",$counter);
}
Incidentally you may want to check out the modulo operator (%) which gives the remainder of a division so:
3%2; // would be 1
4%2; // would be 0
This would save you creating all those temporary variables and running three instructions per number you print, which could slow things down on a large set of numbers ;)
You may also want to look at a mathematical method for finding the prime numbers in a set, called the "Net of Erostothenes"
Cheers,
Charlie
--
Don't Stand on your head - you'll get footprints in your hair
http://charlieharvey.org.uk
http://charlieharvey.com