Gamma function: Difference between revisions

Content deleted Content added
m Fixed lang tags.
Line 12:
=={{header|Ada}}==
The implementation uses [[wp:Taylor series|Taylor series]] coefficients of <math>\Gamma(x+1)^{-1}, |x|<\infty</math>. The coefficients are taken from ''Mathematical functions and their approximations'' by [[wp:Yudell Luke|Yudell L. Luke]].
<lang ada>function Gamma (X : Long_Float) return Long_Float is
<lang ada>
function Gamma (X : Long_Float) return Long_Float is
A : constant array (0..29) of Long_Float :=
( 1.00000_00000_00000_00000,
Line 53 ⟶ 52:
end loop;
return 1.0 / Sum;
end Gamma;</lang>
</lang>
Test program:
<lang ada>with Ada.Text_IO; use Ada.Text_IO;
with Ada.Text_IO; use Ada.Text_IO;
with Gamma;
 
Line 65 ⟶ 62:
Put_Line (Long_Float'Image (Gamma (Long_Float (I) / 3.0)));
end loop;
end Test_Gamma;</lang>
</lang>
Sample output:
<pre>
Line 89 ⟶ 85:
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}}
<!-- {{does not work with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release 1.8.8d.fc9.i386 - formatted transput is missing, gamma is an extension, and various LONG vs INT operators missing}} -->
<lang algolalgol68># Coefficients used by the GNU Scientific Library #
[]LONG REAL p = ( LONG 0.99999 99999 99809 93,
LONG 676.52036 81218 851,