Jump to content

Pythagorean quadruples: Difference between revisions

Added XPL0 example.
m (syntax highlighting fixup automation)
(Added XPL0 example.)
Line 2,352:
System.print()</syntaxhighlight>
 
{{out}}
<pre>
1 2 4 5 8 10 16 20 32 40 64 80 128 160 256 320 512 640 1024 1280 2048
</pre>
 
=={{header|XPL0}}==
{{trans|C}}
Twenty-seven seconds on my (cheap) Raspberry Pi 4.
<syntaxhighlight lang "XPL0">def N = 2200;
int A, B, C, D, AABB, AABBCC;
char R(N+1);
[FillMem(R, 0, N+1); \zero solution array
for A:= 1 to N do
[for B:= A to N do
[if (A&1 and B&1) = 0 then \for positive odd A and B, no solution
[AABB:= A*A + B*B;
for C:= B to N do
[AABBCC:= AABB + C*C;
D:= sqrt(AABBCC);
if AABBCC = D*D and D <= N then R(D):= 1; \solution
];
];
];
];
for A:= 1 to N do
if R(A) = 0 then
[IntOut(0, A); ChOut(0, ^ )]; \print non-solutions
CrLf(0);
]</syntaxhighlight>
{{out}}
<pre>
296

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.