Two version - brute force and recursive.