1
0
forked from kalmar/DALGLI0
DALGLI0/02-rozwiazanie.js
2018-07-01 15:17:38 +02:00

22 lines
539 B
JavaScript

let Polynomial = require('./polynomial.js');
let mul, div, gcd;
let n = parseInt(process.argv[2]);
let p1 = JSON.parse(process.argv[3].replace(/'/g, '"'));
let p2 = JSON.parse(process.argv[4].replace(/'/g, '"'));
let f = new Polynomial.Class(n, p1);
let g = new Polynomial.Class(n, p2);
mul = Polynomial.multiply(f, g).coefficients;
try {
div = Polynomial.divide(f, g).coefficients
} catch (e) {
console.log(e)
}
try {
gcd = Polynomial.gcd(f, g).coefficients;
} catch (e) {
console.log(e);
}
console.log([mul, div, gcd])