2 bernoulli - Bernoulli number
8 n integer, n < 2^31 if even
13 Returns the Bernoulli number with index n, i.e. the coefficient B_n in
16 t/(exp(t) - 1) = Sum B_n * t^n/n!
18 bernoulli(n) is zero both for n < 0 and for n odd and > 2.
19 When bernoulli(n) is computed for positive even n, the values for
20 n and smaller positive even indices are stored in a table so that
21 a later call to bernoulli(k) with 0 <= k < n will be executed quickly.
23 Considerable runtime and memory are required for calculating
24 bernoulli(n) for large even n. For n = 1000, the numerator has
25 1779 digits, the denominator 9 digits.
27 The memory used to store calculated bernoulli numbers is freed by
31 ; config("mode", "frac"),;
32 ; for (n = 0; n <= 6; n++) print bernoulli(n),; print;
33 1 -1/2 1/6 0 -1/30 0 1/42
39 NUMBER *qbernoulli(long n)
42 euler, catalan, comb, fact, perm
44 ## Copyright (C) 2000 Ernest Bowen
46 ## Calc is open software; you can redistribute it and/or modify it under
47 ## the terms of the version 2.1 of the GNU Lesser General Public License
48 ## as published by the Free Software Foundation.
50 ## Calc is distributed in the hope that it will be useful, but WITHOUT
51 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
52 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
53 ## Public License for more details.
55 ## A copy of version 2.1 of the GNU Lesser General Public License is
56 ## distributed with calc under the filename COPYING-LGPL. You should have
57 ## received a copy with calc; if not, write to Free Software Foundation, Inc.
58 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
60 ## @(#) $Revision: 30.1 $
61 ## @(#) $Id: bernoulli,v 30.1 2007/03/16 11:10:42 chongo Exp $
62 ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/bernoulli,v $
64 ## Under source code control: 2000/07/13 01:33:00
65 ## File existed as early as: 2000
67 ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/