Horner's rule for polynomial evaluation: Difference between revisions
Horner's rule for polynomial evaluation (view source)
Revision as of 21:40, 20 January 2011
, 13 years agoGo solution
(Go solution) |
|||
Line 257:
Output:
<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}}==
|