JSFiddle - React, Tailwind, and code Playground
HTML
<pre id="out"></pre>
JavaScript
var partition = function(n) {
var sigma=[], p=[], i,j, BigInt;
// This is a very simple BigInt implementation which doesn't
// support e.g. negative numbers.
BigInt = function(val) {
var end;
if (typeof val === typeof 0) {
this.val = val < this.N ? [val] : [val % this.N, val / this.N];
}
else {
end = val.length;
while (end > 1 && val[end-1]===0) end--;
this.val = val.slice(0, end);
}
}
BigInt.prototype.N = 100000000000000;
BigInt.prototype.sqrtN = 10000000;
// Add another BigInt
BigInt.prototype.add = function(y) {
var c=0,i,n=(this.val.length > y.val.length ? this : y).val.length,sum=[],N=this.N;
for (i=0; i<n; i++) {
sum[i] = (this.val[i]||0) + (y.val[i]||0) + c;
c = Math.floor(sum[i] / N);
if (c) sum[i] -= N;
}
if (c) sum[n]=c;
return new BigInt(sum);
};
// Multiply by another BigInt
BigInt.prototype.mul = function(y) {
var m=[],i,j,tmp,N=this.N;
for (i=0; i<this.val.length + y.val.length + 1; i++)
m[i] = 0;
for (i=0; i<this.val.length; i++)
for (j=0; j<y.val.length; j++) {
tmp = this.mul_inner(this.val[i], y.val[j]);
m[i+j] += tmp[0];
m[i+j+1] += tmp[1];
if (m[i+j] >= N) {
m[i+j+1] += Math.floor(m[i+j] / N);
m[i+j] %= N;
}
if (m[i+j+1] >= N) {
m[i+j+2] += Math.floor(m[i+j+1] / N);
m[i+j+1] %= N;
}
}
return new BigInt(m);
}
// Helper for mul
BigInt.prototype.mul_inner = function(x, y) {
var sqrtN=this.sqrtN,N=this.N,
a=Math.floor(x/sqrtN),b=x%sqrtN,
c=Math.floor(y/sqrtN),d=y%sqrtN,
m=[b*d, a*c];
a = b*c + a*d;
m[0] += (a...