solved fifth problem brute force, 40s runtime though, perhaps prime factorization is a better solution