V
V
vision-bk2015-10-17 18:36:24
Algorithms
vision-bk, 2015-10-17 18:36:24

How to generate all polynomials of the specified degree?

Let one polynomial be represented as an array containing its coefficients (over the field of residues modulo 2). Some degree is introduced, and all polynomials of this degree must be generated programmatically. All received arrays are stored in List. It’s not difficult to calculate manually, especially if you represent the coefficients as 0 and 1, but I can’t figure out how to do it programmatically.
For clarity of the question, I will give polynomials of degree 2:
001
011
101
111
We need an algorithm for programmatic generation of these coefficients.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dtestyk, 2015-10-17
@vision-bk

try like this:

n=3;
for(i=0; i<1<<n; i++){
  s=''
  for(j=0; j<n; j++){
    s+=(i>>j)&1+' '
  }
  s+='1'
  console.log(s)
}

A
abcd0x00, 2015-10-19
@abcd0x00

Why generate them if they are just binary numbers in order?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question