Changed slightly problem004 implementation
Solved problems 6 and 7