Attempt at problem 3

Doesn't work with large enough numbers