Generator/Exponential: Difference between revisions

m
Moved Wren entry into correct alphabetical order.
m (→‎{{header|Wren}}: Changed to Wren S/H)
m (Moved Wren entry into correct alphabetical order.)
 
Line 4,354:
1024
1089</pre>
 
=={{header|XPL0}}==
<syntaxhighlight lang="xpl0">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
]</syntaxhighlight>
 
{{out}}
<pre>
529 576 625 676 784 841 900 961 1024 1089
</pre>
 
=={{header|Wren}}==
Line 4,423 ⟶ 4,391:
}
System.print()</syntaxhighlight>
 
{{out}}
<pre>
529 576 625 676 784 841 900 961 1024 1089
</pre>
 
=={{header|XPL0}}==
<syntaxhighlight lang="xpl0">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
]</syntaxhighlight>
 
{{out}}
9,482

edits