Added SmallestPrime function. Also, algorithm had to be modified due to the issue from #1