Steady squares: Difference between revisions

Added PL/0
(Added PL/0)
Line 1,463:
</pre>
Which is a whopping 35-fold speedup, so obviously ''all'' I need to do is make the compiler emit similarly efficient code...
 
=={{header|PL/0}}==
<syntaxhighlight lang="pascal">
const maxnumber = 10000;
var p10, n, d, nd, n2;
begin
p10 := 10;
n := 0;
while n <= maxnumber do begin
if n = p10 then p10 := p10 * 10;
d := 0;
while d < 6 do begin
if d = 5 then d := 6;
if d = 1 then d := 5;
if d = 0 then d := 1;
nd := n + d;
n2 := nd * nd;
n2 := n2 - ( ( n2 / p10 ) * p10 );
if n2 = nd then ! nd
end;
n := n + 10
end
end.
</syntaxhighlight>
{{out}}
<pre>
1
5
6
25
76
376
625
9376
</pre>
 
=={{header|PL/M}}==
Line 1,657 ⟶ 1,692:
9376**2: 87909376
</pre>
 
=={{header|Prolog}}==
works with swi-prolog
3,021

edits