Continued fraction/Arithmetic/Construct from rational number: Difference between revisions

Content added Content deleted
(→‎{{header|Tcl}}: More tweaks)
m (→‎{{header|REXX}}: Separated the rambling paragraph to make it more readable, then sentences are disjoint enough to warrant their own paragraphs. -- ~~~~)
Line 223: Line 223:


The   '''numeric digits'''   can be increased to a higher value to generate more terms.
The   '''numeric digits'''   can be increased to a higher value to generate more terms.
Two subroutines   '''sqrt'''   &   '''pi'''   were included here to demonstrate terms for   √2   and   π.
<br>Two subroutines &nbsp; '''sqrt''' &nbsp; &amp; &nbsp; '''pi''' &nbsp; were included here to demonstrate terms for &nbsp; √2 &nbsp; and &nbsp; π.
The subroutine &nbsp; '''$maxfact''' &nbsp; was included and is only needed if the number used for &nbsp; '''r2cf''' &nbsp; is a decimal fraction.
<br>The subroutine &nbsp; '''$maxfact''' &nbsp; was included and is only needed if the number used for &nbsp; '''r2cf''' &nbsp; is a decimal fraction.
Checks were included to verify that the arguments being passed to &nbsp; '''r2cf''' &nbsp; are indeed numeric and also not zero.
<br>Checks were included to verify that the arguments being passed to &nbsp; '''r2cf''' &nbsp; are indeed numeric and also not zero.
This version handles negative numbers.
<br>This version handles negative numbers.
<lang rexx>/*REXX pgm converts decimal or rational fraction to a continued fraction*/
<lang rexx>/*REXX pgm converts decimal or rational fraction to a continued fraction*/
numeric digits 230 /*this determines how many terms */
numeric digits 230 /*this determines how many terms */