Jump to content

Averages/Root mean square: Difference between revisions

m
→‎{{header|REXX}}: added overflow to 'style', changed comments, added comments, added whitespace. -- ~~~~
m (→‎{{header|Perl 6}}: punctuation reduction)
m (→‎{{header|REXX}}: added overflow to 'style', changed comments, added comments, added whitespace. -- ~~~~)
Line 838:
<br>calculation as well as a reasonable attempt at providing a first-guess square root by essentially halving
<br>the number using logrithmic (base ten) arithmetic.
<lang rexx>/*REXX program to compute the root mean square. of a series of numbers.*/
 
parse arg n . /*get the argument (maybe). */
if n=='' then n=10 /*if notNot specified,? Then assume ten10. */
numeric digits 50 /*let's go a little overboard. */
sum=0 /*sum of numbers squared (so far)*/
Line 848:
end /*j*/
rms=sqrt(sum/n) /*divide by N, then get SQRT. */
say 'root mean square for 1──>1──►'n "is" rms /*show & tell.*/
exit /*stick a fork in it, we're done.*/
exit
 
/*──────────────────────────────────SQRT subroutine─────────────────────────*/
sqrt: procedure; parse arg x;if x=0 then return 0;d=digits();numeric digits 11
Line 859 ⟶ 858:
p=d+d%4+2; parse value format(x,2,1,,0) 'E0' with g 'E' _ .; return g*.5'E'_%2</lang>
'''output'''
<pre style="overflow:scroll">
<pre>
root mean square for 1──>101──►10 is 6.2048368229954282980666209777247378499279652953641
</pre>
 
Cookies help us deliver our services. By using our services, you agree to our use of cookies.