implementation of factorial as stack - for academy