Solves project euler question #2