@Chris'sister considering that others have written a very shorter version yes. Also, while you have used all the gamma stuff, one solution has a very simple substitution.
But that is not a reason for downvote I would say, it is always important to know as many methods as possible,