Compute Bernoulli number Bn
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | n |
Serial number |
||
| real(kind=wp), | intent(out) | :: | Bn(0:n) |
|
subroutine bernoa(n,Bn) integer,intent(in) :: n !! Serial number real(wp),intent(out) :: Bn(0:n) !! `Bn` real(wp) :: r , s integer :: j , k , m Bn(0) = 1.0_wp Bn(1) = -0.5_wp do m = 2 , n s = -(1.0_wp/(m+1.0_wp)-0.5_wp) do k = 2 , m - 1 r = 1.0_wp do j = 2 , k r = r*(j+m-k)/j enddo s = s - r*Bn(k) enddo Bn(m) = s enddo do m = 3 , n , 2 Bn(m) = 0.0_wp enddo end subroutine bernoa