Commit e9d0bc8c authored by ulrich_y's avatar ulrich_y

Slimmed bernoulli outer do loop

parent 813c6de9
......@@ -60,21 +60,20 @@ CONTAINS
integer, parameter :: nmax = 40
! keep track of the bernoulli numbers we have already calculated
real(kind=prec), save :: bernoulli(0:nmax) = 0.
integer, save :: cmax = 2
integer m, k
integer, save :: m = 2
integer k
!TODO error handling or dynamic allocation for bernoulli(:)
bernoulli(0) = 1.
bernoulli(1) = -0.5
do m=cmax,n,2
do m=m,n,2
bernoulli(m) = 0.
do k=0,m-1
bernoulli(m) = bernoulli(m) - binom(m, k) * bernoulli(k) / (m - k + 1)
enddo
enddo
cmax=m
bernoullinumber = bernoulli(n)
END FUNCTION bernoullinumber
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment