1
0
forked from kalmar/DALGLI0
DALGLI0/02-rozwiazanie.js

22 lines
539 B
JavaScript
Raw Normal View History

2018-06-29 16:10:38 +02:00
let Polynomial = require('./polynomial.js');
let mul, div, gcd;
2018-06-29 19:35:57 +02:00
2018-06-29 16:10:38 +02:00
let n = parseInt(process.argv[2]);
2018-07-01 15:17:38 +02:00
let p1 = JSON.parse(process.argv[3].replace(/'/g, '"'));
let p2 = JSON.parse(process.argv[4].replace(/'/g, '"'));
2018-06-29 19:35:57 +02:00
2018-07-01 11:35:34 +02:00
let f = new Polynomial.Class(n, p1);
let g = new Polynomial.Class(n, p2);
mul = Polynomial.multiply(f, g).coefficients;
2018-06-29 16:10:38 +02:00
try {
2018-07-01 11:35:34 +02:00
div = Polynomial.divide(f, g).coefficients
2018-06-29 16:10:38 +02:00
} catch (e) {
console.log(e)
}
try {
2018-07-01 11:35:34 +02:00
gcd = Polynomial.gcd(f, g).coefficients;
2018-06-29 16:10:38 +02:00
} catch (e) {
console.log(e);
}
console.log([mul, div, gcd])