some refactoring in the prime generation method, oblig 2, discrete maths

Signed-off-by: Alexander Skjolden <alex@plastboks.net>