Paraffins: Difference between revisions

m (added an image of a paraffins: isopentane (common name).)
Line 964:
249: 5814271898167303040368103945830220447130073898083466852225709084407144308593691069932064987528870826155297
250: 16206624309085062837751018464745815688226709117091506494175397665527493805947344857313038875654104100026504</pre>
 
=={{header|PARI/GP}}==
 
This function is for recent PARI/GP:
<lang parigp>paraffin(p) =
{
local (P = p+1, R, U = R = Vec([1,1], P));
 
for (n = 1, p,
((B,n,C,S,l=n) -> my(b,c,i,s);
for (b = 1, 4-B,
if ((s = S + b * n) < P,
c = R[n+1] * C * prod(i = 1, b-1, (R[n+1]+i) / (i+1)) ;
if (l+l < s, U[s+1] += c);
if (B+b < 4, R[s+1] += c; i = n; while (i--, self()(B+b, i, c, s, l)))))
)(0,n,1,1);
if (n % 2,, U[n+1] += R[n/2+1] * (R[n/2+1]+1) / 2);
print([n, U[n+1]]))
}</lang>
 
 
Code for older version of PARI/GP < 2.9:
<lang parigp>iso(B,n,C,S,l=n) =
{
my(b,c,i,s);
 
for (b = 1, 4-B,
if ((s = S + b * n) < P,
c = R[n+1] * C * prod(i = 1, b-1, (R[n+1]+i) / (i+1));
if (l+l < s, U[s+1] += c);
if (B+b < 4, R[s+1] += c; i = n; while (i--, iso(B+b, i, c, s, l)))))
}
 
paraffin(p) =
{
local (P = p+1, R, U = R = Vec([1,1], P));
 
for (n = 1, p, iso(0, n, 1, 1);
if (n % 2,, U[n+1] += R[n/2+1] * (R[n/2+1]+1) / 2);
print([n, U[n+1]]))
}</lang>
 
 
Output:<pre>paraffin(32)
 
[1, 1]
[2, 1]
[3, 1]
[4, 2]
[5, 3]
[6, 5]
[7, 9]
[8, 18]
[9, 35]
[10, 75]
[11, 159]
[12, 355]
[13, 802]
[14, 1858]
[15, 4347]
[16, 10359]
[17, 24894]
[18, 60523]
[19, 148284]
[20, 366319]
[21, 910726]
[22, 2278658]
[23, 5731580]
[24, 14490245]
[25, 36797588]
[26, 93839412]
[27, 240215803]
[28, 617105614]
[29, 1590507121]
[30, 4111846763]
[31, 10660307791]
[32, 27711253769]
</pre>
 
=={{header|Pascal}}==
Anonymous user