Simple algorhythm for calculating primes in c