Adding problem 39.

Bruteforce method...