Bernoulli numbers: Difference between revisions

m
→‎{{header|factor}}: capitalize language name, change some non-code whitespace
m (→‎{{header|factor}}: capitalize language name, change some non-code whitespace)
Line 985:
B(60) = -1215233140483755572040304994079820246041491 / 56786730
</pre>
=={{header|factorFactor}}==
One could use the "bernoulli" word from the math.extras vocabulary as follows:
<lang>IN: scratchpad
IN: scratchpad
[
0 1 1 "%2d : %d / %d\n" printf
Line 1,029 ⟶ 1,028:
58 : 84483613348880041862046775994036021 / 354
60 : -1215233140483755572040304994079820246041491 / 56786730
Running time: 0.00489444 seconds</lang>
</lang>
Alternatively a method described by Brent and Harvey (2011) in "Fast computation of Bernoulli, Tangent and Secant numbers" https://arxiv.org/pdf/1108.0286.pdf is shown.
<lang>:: bernoulli-numbers ( n -- )
<lang>
:: bernoulli-numbers ( n -- )
n 1 + 0 <array> :> tab
1 1 tab set-nth
Line 1,067 ⟶ 1,064:
"%2d : %d / %d\n" printf
] each
;</lang>
;
</lang>
It gives the same result as the native implementation, but is slightly faster.
<lang>[ 30 bernoulli-numbers ] time
<lang>
[ 30 bernoulli-numbers ] time
...
Running time: 0.004331652 seconds</lang>
</lang>
 
=={{header|FreeBASIC}}==
1,808

edits