this is a prime n algorithm