Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
25
Task/Generator-Exponential/XPL0/generator-exponential.xpl0
Normal file
25
Task/Generator-Exponential/XPL0/generator-exponential.xpl0
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
code ChOut=8, IntOut=11;
|
||||
|
||||
func Gen(M); \Generate Mth powers of positive integers
|
||||
int M;
|
||||
int N, R, I;
|
||||
[N:= [0, 0, 0, 0]; \provides own/static variables
|
||||
R:= 1;
|
||||
for I:= 1 to M do R:= R*N(M);
|
||||
N(M):= N(M)+1;
|
||||
return R;
|
||||
];
|
||||
|
||||
func Filter; \Generate squares of positive integers that aren't cubes
|
||||
int S, C;
|
||||
[C:= [0]; \static variable = smallest cube > current square
|
||||
repeat S:= Gen(2);
|
||||
while S > C(0) do C(0):= Gen(3);
|
||||
until S # C(0);
|
||||
return S;
|
||||
];
|
||||
|
||||
int I;
|
||||
[for I:= 1 to 20 do Filter; \drop first 20 values
|
||||
for I:= 1 to 10 do [IntOut(0, Filter); ChOut(0, ^ )]; \show next 10 values
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue