Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
20
Task/Pythagorean-triples/Phix/pythagorean-triples.phix
Normal file
20
Task/Pythagorean-triples/Phix/pythagorean-triples.phix
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
atom total, prim, maxPeri = 10
|
||||
|
||||
procedure tri(atom s0, s1, s2)
|
||||
atom p = s0 + s1 + s2
|
||||
if p<=maxPeri then
|
||||
prim += 1
|
||||
total += floor(maxPeri/p)
|
||||
tri( s0+2*(-s1+s2), 2*( s0+s2)-s1, 2*( s0-s1+s2)+s2);
|
||||
tri( s0+2*( s1+s2), 2*( s0+s2)+s1, 2*( s0+s1+s2)+s2);
|
||||
tri(-s0+2*( s1+s2), 2*(-s0+s2)+s1, 2*(-s0+s1+s2)+s2);
|
||||
end if
|
||||
end procedure
|
||||
|
||||
while maxPeri<=1e8 do
|
||||
prim := 0;
|
||||
total := 0;
|
||||
tri(3, 4, 5);
|
||||
printf(1,"Up to %d: %d triples, %d primitives.\n", {maxPeri,total,prim})
|
||||
maxPeri *= 10;
|
||||
end while
|
||||
Loading…
Add table
Add a link
Reference in a new issue