RosettaCodeData/Task/Pi/NetRexx/pi.netrexx

63 lines
1.9 KiB
Plaintext

/* NetRexx */
options replace format comments java crossref symbols binary
import java.math.BigInteger
runSample(arg)
return
-- 07:11, 27 August 2022 (UTC)07:11, 27 August 2022 (UTC)07:11, 27 August 2022 (UTC)07:11, 27 August 2022 (UTC)07:11, 27 August 2022 (UTC)07:11, 27 August 2022 (UTC)07:11, 27 August 2022 (UTC)07:11, 27 August 2022 (UTC)07:11, 27 August 2022 (UTC)07:11, 27 August 2022 (UTC)07:11, 27 August 2022 (UTC)07:11, 27 August 2022 (UTC)07:11, 27 August 2022 (UTC)07:11, 27 August 2022 (UTC)07:11, 27 August 2022 (UTC)~~
method runSample(arg) private static
parse arg places .
if places = '' then places = -1
TWO = BigInteger.valueOf(2)
THREE = BigInteger.valueOf(3)
FOUR = BigInteger.valueOf(4)
SEVEN = BigInteger.valueOf(7)
q_ = BigInteger.ONE
r_ = BigInteger.ZERO
t_ = BigInteger.ONE
k_ = BigInteger.ONE
n_ = BigInteger.valueOf(3)
l_ = BigInteger.valueOf(3)
nn = BigInteger
nr = BigInteger
first = isTrue()
digitCt = 0
loop forever
if FOUR.multiply(q_).add(r_).subtract(t_).compareTo(n_.multiply(t_)) == -1 then do
digitCt = digitCt + 1
if places > 0 & digitCt - 1 > places then leave
say n_'\-'
if first then do
say '.\-'
first = isFalse()
end
nr = BigInteger.TEN.multiply(r_.subtract(n_.multiply(t_)))
n_ = BigInteger.TEN.multiply(THREE.multiply(q_).add(r_)).divide(t_).subtract(BigInteger.TEN.multiply(n_))
q_ = q_.multiply(BigInteger.TEN)
r_ = nr
end
else do
nr = TWO.multiply(q_).add(r_).multiply(l_)
nn = q_.multiply((SEVEN.multiply(k_))).add(TWO).add(r_.multiply(l_)).divide(t_.multiply(l_))
q_ = q_.multiply(k_)
t_ = t_.multiply(l_)
l_ = l_.add(TWO)
k_ = k_.add(BigInteger.ONE)
n_ = nn
r_ = nr
end
end
say
return
method isTrue() private static returns boolean
return (1 == 1)
method isFalse() private static returns boolean
return \isTrue()