created a factorial accumulator via helper function