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(p1); let g = new Polynomial.Class(p2); mul = Polynomial.multiply(f, g, 2).coefficients; try { div = Polynomial.divide(f, g, 2).coefficients } catch (e) { console.log(e) } try { gcd = Polynomial.gcd(f, g, 2).coefficients; } catch (e) { console.log(e); } console.log([mul, div, gcd])