Parallel version of problem 10