Problem 015 rewritten