RosettaCodeData/Task/Continued-fraction/XPL0/continued-fraction.xpl0
2023-07-01 13:44:08 -04:00

25 lines
550 B
Text

include c:\cxpl\codes;
int N;
real A, B, F;
[Format(1, 15);
A:= 2.0; B:= 1.0; N:= 16;
IntOut(0, N); CrLf(0);
F:= 0.0;
while N>=1 do [F:= B/(A+F); N:= N-1];
RlOut(0, 1.0+F); CrLf(0);
RlOut(0, sqrt(2.0)); CrLf(0);
N:= 13;
IntOut(0, N); CrLf(0);
F:= 0.0;
while N>=2 do [F:= float(N-1)/(float(N)+F); N:= N-1];
RlOut(0, 2.0 + 1.0/(1.0+F)); CrLf(0);
RlOut(0, Exp(1.0)); CrLf(0);
N:= 10000;
IntOut(0, N); CrLf(0);
F:= 0.0;
while N>=1 do [F:= float(sq(2*N-1))/(6.0+F); N:= N-1];
RlOut(0, 3.0+F); CrLf(0);
RlOut(0, ACos(-1.0)); CrLf(0);
]