solution to problem 7 and bugfix in IsPrime(long)