The set of all polynomials with integer coefficients is countable. This means that there is a sequence that contains each polynomial with integer coefficients exactly once.
Your goal is it to write a function or program that outputs such a sequence.
Example (you may use another sequence):
// list of integers [i -> Z(i)] : 0,1,-1,2,-2,...
// integer -> polynomial
// 1. factor index n=product_i p_i^k_i
// 2. return polynomial sum_i Z(k_i)*x^(i-1)
1 -> 0 // all powers 0 -> all summands 0
2 -> 1 // 2^1 -> 1*x^0
3 -> x // 3^1 -> 1*x^1
4 -> -1 // 2^2 -> -1*x^0
5 -> x² // 5^1 -> 1*x^2
6 -> x+1 // 2^1*3^1 -> 1*x^0+1*x^1
7 -> x³ // 7^1 -> 1*x^3
8 -> 2 // 2^3 -> 2*x^0
9 -> -x // 3^2 -> -1*x^1
...
For ideas how to compute the sequence of all integers see here
Rules:
- Each integer polynomial has to (eventually) appear in the sequence generated by your program
- Polynomials are not allowed to appear more than once
- The standard sequence IO-rules apply
- You may output polynomials as lists of coefficients
- Using the empty string/list to represent zero is allowed
- You are allowed to output the coefficients in reverse order (constant coefficient on the left)
- This is code-golf the shortest program (per language) wins.
1,,2
to represent1*x^2+0*x+2
? \$\endgroup\$