I know there are various forms to express the function $P(n)$, the number of partitions for an integer $n$, e.g. see some of the formulas referenced on Wolfram.
But say I only care about the first ~$10-20$ numbers ($P(n)$ for $n \lt$ ~$20$).
E.g. from OEIS:, the sequence (up to $n=20$): $$1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 77, 101, 135, 176, 231, 297, 385, 490$$
But is there a "relatively simple" exact closed form expression for the first $10-20$ values of $n$? Relatively simple meaning e.g. an expression for $P(n)$, $n \le$ ~$10-20$, that someone could calculate reasonably quickly on a basic calculator (products and sums okay, but e.g. no Bessel functions or something). Also, no approximate solutions, only exact solutions.
Yes, it is possible to calculate a closed form, but it is not so nice. Anyway the calculation is relative simple, and once it is calculated you just need to apply the formula, so here it is (the explanation of the theory below is much larger than the code required to use it):
This constant is such that:
I am using a method of my own (I asked about it some weeks ago but unfortunately still was not answered).
The constant has a lot of decimal places, but if you are using PARI/GP you can calculate it and use it and it will provide the exact values of $P(n)$ for $n=[1,20]$.
This is the manual method to generate the constant $P$ (it is much better described in my original question applied to other encapsulation problem):
... up to:
Then using same theory as Mills' constant, our constant is $P=E_{20}^{(\frac{1}{2^{20}})} = 1.366611510803...$.
You will require a good amount of decimal places to have enough precision to use it and obtain the values, but it works and can be used for calculations.
For instance in PARI/GP first you calculate up to $E_{20}$, then calculate the constant $P$ with $E_{20}$, and then you can apply the formula to obtain the exact values of $P(1)..P(20)$ from that moment (so for instance you can store the value of the constant $P$ in a library and build a function to use it):
And then you can use $P$ as follows:
Be aware that $f(P,1)$ ($P01$ in the code) is an special case and that is the reason of the correction term $+\frac{\lvert n-(\frac{1}{2}) \rvert}{(\frac{1}{2})-n}$.