RosettaCodeData/Task/Combinations-and-permutations/Phix/combinations-and-permutations-2.phix
2016-12-05 23:44:36 +01:00

22 lines
587 B
Text

printf(1,"=> Exact results:\n")
for n=1 to 12 do
integer p = floor(n/3)
printf(1,"P(%d,%d) = %d\n",{n,p,P(n,p)})
end for
for n=10 to 60 by 10 do
integer p = floor(n/3)
printf(1,"C(%d,%d) = %d\n",{n,p,C(n,p)})
end for
printf(1,"=> Floating point approximations:\n")
constant tests = {5, 50, 500, 1000, 5000, 15000}
for i=1 to length(tests) do
integer n=tests[i], p = floor(n/3)
printf(1,"P(%d,%d) = %s\n",{n,p,to_s(P_approx(n,p))})
end for
for n=100 to 1000 by 100 do
integer p = floor(n/3)
printf(1,"C(%d,%d) = %s\n",{n,p,to_s(C_approx(n,p))})
end for