Jump to content

Polynomial long division: Difference between revisions

m
→‎{{header|E}}: simplify printing, fix bug with zero polynomial
(→‎E: new example)
m (→‎{{header|E}}: simplify printing, fix bug with zero polynomial)
Line 250:
if (i < 0) { -Infinity } else { i }
}
def coeffs := initCoeffs(0, if (degree == -Infinity) { [] } else { degree + 1 })
def polynomial {
/** Print the polynomial (not necessary for the task) */
to __printOn(out) {
out.print("(λx. ")
var first := true
for i in (0..!(coeffs.size())).descending() {
def coeff := coeffs[i]
if (coeff <=> 0) { continue }
if (!first) { out.print(" ") }
if (coeff <=> 1 && !(i <=> 0)) {
# no coefficient written if it's 1 and not the constant term
Cookies help us deliver our services. By using our services, you agree to our use of cookies.