project euler #31 update: moving array slice out of for loop