Horner's rule for polynomial evaluation: Difference between revisions

Added C#.
(Pari/GP)
(Added C#.)
Line 105:
return 0;
}</lang>
=={{header|C sharp|C#}}==
<lang csharp>using System;
using System.Linq;
 
class Program
{
static double Horner(double[] coefficients, double variable)
{
return coefficients.Reverse().Aggregate((accumulator, coefficient) => accumulator * variable + coefficient);
}
 
static void Main()
{
Console.WriteLine(Horner(new[] { -19.0, 7.0, -4.0, 6.0 }, 3.0));
}
}</lang>
Output:
<lang>128</lang>
=={{header|C++}}==
The same C function works too, but another solution could be:
Anonymous user