Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
53
Task/Continued-fraction/NetRexx/continued-fraction.netrexx
Normal file
53
Task/Continued-fraction/NetRexx/continued-fraction.netrexx
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/* REXX ***************************************************************
|
||||
* Derived from REXX ... Derived from PL/I with a little "massage"
|
||||
* SQRT2= 1.41421356237309505 <- PL/I Result
|
||||
* 1.41421356237309504880168872421 <- NetRexx Result 30 digits
|
||||
* NAPIER= 2.71828182845904524
|
||||
* 2.71828182845904523536028747135
|
||||
* PI= 3.14159262280484695
|
||||
* 3.14159262280484694855146925223
|
||||
* 07.09.2012 Walter Pachl
|
||||
* 08.09.2012 Walter Pachl simplified (with the help of a friend)
|
||||
**********************************************************************/
|
||||
options replace format comments java crossref savelog symbols
|
||||
class CFB public
|
||||
|
||||
properties static
|
||||
Numeric Digits 30
|
||||
Sqrt2 =1
|
||||
napier=2
|
||||
pi =3
|
||||
a =0
|
||||
b =0
|
||||
|
||||
method main(args = String[]) public static
|
||||
Say 'SQRT2='.left(7) calc(sqrt2, 200)
|
||||
Say 'NAPIER='.left(7) calc(napier, 200)
|
||||
Say 'PI='.left(7) calc(pi, 200)
|
||||
Return
|
||||
|
||||
method get_Coeffs(form,n) public static
|
||||
select
|
||||
when form=Sqrt2 Then do
|
||||
if n > 0 then a = 2; else a = 1
|
||||
b = 1
|
||||
end
|
||||
when form=Napier Then do
|
||||
if n > 0 then a = n; else a = 2
|
||||
if n > 1 then b = n - 1; else b = 1
|
||||
end
|
||||
when form=pi Then do
|
||||
if n > 0 then a = 6; else a = 3
|
||||
b = (2*n - 1)**2
|
||||
end
|
||||
end
|
||||
Return
|
||||
|
||||
method calc(form,n) public static
|
||||
temp=0
|
||||
loop ni = n to 1 by -1
|
||||
Get_Coeffs(form,ni)
|
||||
temp = b/(a + temp)
|
||||
end
|
||||
Get_Coeffs(form,0)
|
||||
return (a + temp)
|
||||
Loading…
Add table
Add a link
Reference in a new issue