Anonymous user
Horner's rule for polynomial evaluation: Difference between revisions
Horner's rule for polynomial evaluation (view source)
Revision as of 18:37, 8 April 2016
, 8 years ago→version 1: added/changed comments, indentations, and whitespace.
No edit summary |
m (→version 1: added/changed comments, indentations, and whitespace.) |
||
Line 1,451:
=={{header|REXX}}==
===version 1===
<lang rexx>/*REXX program
numeric digits 30 /*use extra numeric precision. */
parse arg x poly /*get value of X and the coefficients. */
do deg=0 until poly=='' /*get the equation's coefficients.
if deg\==0 & c.deg\=0 then $=$'∙x^'deg /*¬1st coefficient & ¬0? Append X pow.*/
$=$ ' ' /*insert some blanks, make it look nice*/
say '
▲say ' equation = ' equ
a=c.deg
end
▲ end /*j*/
say
say ' answer = ' a /*stick a fork in it, we're all done. */</lang>
'''output''' when the following is used for input: <tt> 3 -19 7 -4 6 </tt>
<pre>
x = 3
Line 1,484 ⟶ 1,480:
answer = 128
</pre>
===version 2===
<lang rexx>/* REXX ---------------------------------------------------------------
|