recursive implementation of factorial