Gamma function: Difference between revisions

No edit summary
Line 607:
1.386831185e+080 1.711224524e+098 8.946182131e+116 1.650795516e+136 9.332621544e+155
*/</lang>
=={{header|AWK}}==
<lang AWK>
# syntax: GAWK -f GAMMA_FUNCTION.AWK
BEGIN {
e = (1+1/100000)^100000
pi = atan2(0,-1)
leng = split("0.99999999999980993,676.5203681218851,-1259.1392167224028,771.32342877765313,-176.61502916214059,12.507343278686905,-0.13857109526572012,9.9843695780195716e-6,1.5056327351493116e-7",p,",")
print("X Stirling")
for (i=1; i<=20; i++) {
d = i / 10
printf("%4.2f %9.5f\n",d,gamma_stirling(d))
}
exit(0)
}
function gamma_stirling(x) {
return sqrt(2*pi/x) * pow(x/e,x)
}
function pow(a,b) {
return exp(b*log(a))
}
</lang>
{{out}}
<pre>
X Stirling
0.10 5.69719
0.20 3.32600
0.30 2.36253
0.40 1.84148
0.50 1.52035
0.60 1.30716
0.70 1.15906
0.80 1.05338
0.90 0.97707
1.00 0.92214
1.10 0.88349
1.20 0.85776
1.30 0.84268
1.40 0.83675
1.50 0.83896
1.60 0.84870
1.70 0.86563
1.80 0.88965
1.90 0.92085
2.00 0.95951
</pre>
 
=={{header|BBC BASIC}}==
477

edits