diff options
author | JODBaer <55744603+JODBaer@users.noreply.github.com> | 2022-07-18 13:54:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-18 13:54:57 +0200 |
commit | eb8cc4b5029fd6fedfd5aaa133fd966a48b643db (patch) | |
tree | 313c7fce3526f271f07180839a5d8dfcf2d1b3a3 /buch/chapters/040-rekursion/gammalimit/l.cpp | |
parent | Merge branch 'AndreasFMueller:master' into master (diff) | |
parent | Merge pull request #21 from enezerdem/master (diff) | |
download | SeminarSpezielleFunktionen-eb8cc4b5029fd6fedfd5aaa133fd966a48b643db.tar.gz SeminarSpezielleFunktionen-eb8cc4b5029fd6fedfd5aaa133fd966a48b643db.zip |
Merge branch 'AndreasFMueller:master' into master
Diffstat (limited to '')
-rw-r--r-- | buch/chapters/040-rekursion/gammalimit/l.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/buch/chapters/040-rekursion/gammalimit/l.cpp b/buch/chapters/040-rekursion/gammalimit/l.cpp new file mode 100644 index 0000000..7a86800 --- /dev/null +++ b/buch/chapters/040-rekursion/gammalimit/l.cpp @@ -0,0 +1,26 @@ +/* + * l.cpp + * + * (c) 2022 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule + */ +#include <cstdlib> +#include <cmath> +#include <cstdio> + +int main(int argc, char *argv[]) { + double x = 0.5; + double g = tgamma(x); + printf("limit: %20.16f\n", g); + double p = 1; + long long N = 100000000000; + long long n = 10; + for (long long k = 1; k <= N; k++) { + p = p * k / (x + k - 1); + if (0 == k % n) { + double gval = p * pow(k, x-1); + printf("%12ld %20.16f %20.16f\n", k, gval, gval - g); + n = n * 10; + } + } + return EXIT_SUCCESS; +} |