Skip to main content
MathJax is enabled!
Source Link
Peter Taylor
  • 43.4k
  • 4
  • 72
  • 179

S(x) & = & x \prod_{i \ge 1} \frac{1}{(1 - x^i)^{2s(i)}} \\ & = & x \prod_{i \ge 1} (1 + x^i + x^{2i} + \ldots)^{2s(i)}$$\begin{eqnarray*}S(x) & = & x \prod_{i \ge 1} \frac{1}{(1 - x^i)^{2s(i)}} \\ & = & x \prod_{i \ge 1} (1 + x^i + x^{2i} + \ldots)^{2s(i)}\end{eqnarray*}$$

S(x) & = & x \prod_{i \ge 1} \frac{1}{(1 - x^i)^{2s(i)}} \\ & = & x \prod_{i \ge 1} (1 + x^i + x^{2i} + \ldots)^{2s(i)}

$$\begin{eqnarray*}S(x) & = & x \prod_{i \ge 1} \frac{1}{(1 - x^i)^{2s(i)}} \\ & = & x \prod_{i \ge 1} (1 + x^i + x^{2i} + \ldots)^{2s(i)}\end{eqnarray*}$$

added 1909 characters in body
Source Link
Peter Taylor
  • 43.4k
  • 4
  • 72
  • 179

Dissection

OEIS gives

G.f.: S(x)+S(x^2)-S(x)^2, where S(x) is the generating function for A000151. - Pab Ter, Oct 12 2005

where

S(x) & = & x \prod_{i \ge 1} \frac{1}{(1 - x^i)^{2s(i)}} \\ & = & x \prod_{i \ge 1} (1 + x^i + x^{2i} + \ldots)^{2s(i)}

{ e# Define a block to convolve two sequences (multiply two polynomials) ee\f{ e# Index one and use the other as an extra parameter for a map \~\0a* e# Stack manipulations; create a sequence of `index` 0s @+f* e# Shift the extra parameter poly and multiply by the coefficient } :.+ e# Fold pointwise add to sum the polys }:C; e# Assign the block to C (for "convolve") 2, e# Initial values of S: S(0) = 0, S(1) = 1 qi:Q e# Read integer and assign it to Q ,2f+{ e# For X = 2 to Q+1 _ee1> e# Duplicate accumulator of S, index, and ditch 0th term { e# Map (over notional variable i) ~2*\ e# Double S(i) and flip i to top of stack ,:! e# Create an array with a 1 and i-1 0s X*X< e# Replicate X times and truncate to X values e# This gives g.f. 1/(1-x^i) to the first X terms a*~ e# Create 2S(i) copies of this polynomial }% {CX<}* e# Fold convolution and truncation to X terms W=+ e# Append the final coefficient, which is S(X), to the accumulator }fX _0a* e# Pad a copy to get S(X^2) 1$_C e# Convolve two copies to get S(X)^2 .- e# Pointwise subtraction .+ e# Pointwise addition. Note the leading space because the parser thinks e# -. is an invalid number Q)= e# Take the term at index Q+1 (where the +1 adjusts for OEIS offset) 

Dissection

OEIS gives

G.f.: S(x)+S(x^2)-S(x)^2, where S(x) is the generating function for A000151. - Pab Ter, Oct 12 2005

where

S(x) & = & x \prod_{i \ge 1} \frac{1}{(1 - x^i)^{2s(i)}} \\ & = & x \prod_{i \ge 1} (1 + x^i + x^{2i} + \ldots)^{2s(i)}

{ e# Define a block to convolve two sequences (multiply two polynomials) ee\f{ e# Index one and use the other as an extra parameter for a map \~\0a* e# Stack manipulations; create a sequence of `index` 0s @+f* e# Shift the extra parameter poly and multiply by the coefficient } :.+ e# Fold pointwise add to sum the polys }:C; e# Assign the block to C (for "convolve") 2, e# Initial values of S: S(0) = 0, S(1) = 1 qi:Q e# Read integer and assign it to Q ,2f+{ e# For X = 2 to Q+1 _ee1> e# Duplicate accumulator of S, index, and ditch 0th term { e# Map (over notional variable i) ~2*\ e# Double S(i) and flip i to top of stack ,:! e# Create an array with a 1 and i-1 0s X*X< e# Replicate X times and truncate to X values e# This gives g.f. 1/(1-x^i) to the first X terms a*~ e# Create 2S(i) copies of this polynomial }% {CX<}* e# Fold convolution and truncation to X terms W=+ e# Append the final coefficient, which is S(X), to the accumulator }fX _0a* e# Pad a copy to get S(X^2) 1$_C e# Convolve two copies to get S(X)^2 .- e# Pointwise subtraction .+ e# Pointwise addition. Note the leading space because the parser thinks e# -. is an invalid number Q)= e# Take the term at index Q+1 (where the +1 adjusts for OEIS offset) 
edited body
Source Link
Stephen
  • 14.2k
  • 3
  • 57
  • 118

1415. CJam, 85 bytes, A000060

{ee\f{\~\0a*@+f*}:.+}:C;2,qi:Q,2f+{_ee1>{~2*\,:!X*X<a*~}%{CX<}*W=+}fX_0a*1$_C.- .+Q)= 

Online demo

Next sequence

14. CJam, 85 bytes, A000060

{ee\f{\~\0a*@+f*}:.+}:C;2,qi:Q,2f+{_ee1>{~2*\,:!X*X<a*~}%{CX<}*W=+}fX_0a*1$_C.- .+Q)= 

Online demo

Next sequence

15. CJam, 85 bytes, A000060

{ee\f{\~\0a*@+f*}:.+}:C;2,qi:Q,2f+{_ee1>{~2*\,:!X*X<a*~}%{CX<}*W=+}fX_0a*1$_C.- .+Q)= 

Online demo

Next sequence

Source Link
Peter Taylor
  • 43.4k
  • 4
  • 72
  • 179
Loading