Horner's rule for polynomial evaluation: Difference between revisions

Content added Content deleted
(Go solution)
Line 257: Line 257:
Output:
Output:
<pre>128.0</pre>
<pre>128.0</pre>
=={{header|Go}}==
<lang go>package main

import "fmt"

func horner(x int64, c []int64) (acc int64) {
for i := len(c) - 1; i >= 0; i-- {
acc = acc*x + c[i]
}
return
}

func main() {
fmt.Println(horner(3, []int64{-19, 7, -4, 6}))
}</lang>


=={{header|Haskell}}==
=={{header|Haskell}}==