let Polynomial = require('./polynomial.js'); let mul, div, gcd; function parseArray(x) { let stringResult = ""; result = Array.from(x).filter(x => { if (x == ' ' || x == '[' || x == ']') return false; else return true; }).join('').split(',').map(x => parseInt(x)); return result; } let n = parseInt(process.argv[2]); let p1 = parseArray(process.argv[3]); let p2 = parseArray(process.argv[4]); 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])