P05 recursive helper version
P05 using reduce