Hello,
I am new to working in C++ and in order to become better acquainted with it I am working on a program that I have no idea how to start. I am trying to create a subroutine that will calculate the gamma function of a real number using the product series expansion of gamma. Any help would be greatly appreciated
Here's a simplistic implementation. Of course Nterms is supposed to be infinite, but that's not possible here. Try the function for various values of Nterms to see how rapidly it converges on the correct value.
In all cases below I found that Nterms = 1,000 is needed to obtain accuracy to just 3 or 4 significant figures. It appears to converge slowly.
Testing with: