Anonymous user
Pythagorean quadruples: Difference between revisions
m
→{{header|Pascal}}: Give i386 a chance und improved runtime for both Cpu64/Cpu32 :-)
m (→{{header|Pascal}}: changed link to Ring version ( estimated runtime in pascal 8h10min (run outer loop 1..32 in 427783 ms ( 2 cpu-cycles per Test ) ) did it ever run?) |
m (→{{header|Pascal}}: Give i386 a chance und improved runtime for both Cpu64/Cpu32 :-)) |
||
Line 1,123:
</pre>
=={{header|Pascal}}==
{{works with|
Stopping search if limit is reached<BR>
<lang pascal>program pythQuad;
//find phythagorean Quadrupel up to a,b,c,d <= 2200
Line 1,131:
//brute force
//split in two procedure to reduce register pressure for CPU32
const
MaxFactor =
limit = MaxFactor*MaxFactor;
type
Line 1,146 ⟶ 1,143:
checkCnt : LongWord;
procedure
//second sum (a*a+b*b) +c*c =?= d*d
var
s1 : tSum;
begin
d := trunc(sqrt(s+idx*idx));// calculate first sqrt
For idx := idx to MaxFactor do
Begin
Line 1,156 ⟶ 1,155:
If s1 <= limit then
Begin
inc(checkCnt);
IF
check[
end
else
Line 1,167 ⟶ 1,166:
end;
procedure
//first sum a*a+b*b
var
begin
For
▲ For j := i to MaxFactor do
Begin
if
Find1(
else
break;
end;
end;
Line 1,189 ⟶ 1,186:
i : NativeUint;
begin
For i := 1 to MaxFactor do
If Not(Check[i]) then
Line 1,199 ⟶ 1,197:
{{out}}
<pre>
1 2 4 5 8 10 16 20 32 40 64 80 128 160 256 320 512 640 1024 1280 2048
929605937 checks were done
real
</pre>
|