September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
42
Task/Bernoulli-numbers/Factor/bernoulli-numbers-1.factor
Normal file
42
Task/Bernoulli-numbers/Factor/bernoulli-numbers-1.factor
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
IN: scratchpad
|
||||
[
|
||||
0 1 1 "%2d : %d / %d\n" printf
|
||||
1 -1 2 "%2d : %d / %d\n" printf
|
||||
30 iota [
|
||||
1 + 2 * dup bernoulli [ numerator ] [ denominator ] bi
|
||||
"%2d : %d / %d\n" printf
|
||||
] each
|
||||
] time
|
||||
0 : 1 / 1
|
||||
1 : -1 / 2
|
||||
2 : 1 / 6
|
||||
4 : -1 / 30
|
||||
6 : 1 / 42
|
||||
8 : -1 / 30
|
||||
10 : 5 / 66
|
||||
12 : -691 / 2730
|
||||
14 : 7 / 6
|
||||
16 : -3617 / 510
|
||||
18 : 43867 / 798
|
||||
20 : -174611 / 330
|
||||
22 : 854513 / 138
|
||||
24 : -236364091 / 2730
|
||||
26 : 8553103 / 6
|
||||
28 : -23749461029 / 870
|
||||
30 : 8615841276005 / 14322
|
||||
32 : -7709321041217 / 510
|
||||
34 : 2577687858367 / 6
|
||||
36 : -26315271553053477373 / 1919190
|
||||
38 : 2929993913841559 / 6
|
||||
40 : -261082718496449122051 / 13530
|
||||
42 : 1520097643918070802691 / 1806
|
||||
44 : -27833269579301024235023 / 690
|
||||
46 : 596451111593912163277961 / 282
|
||||
48 : -5609403368997817686249127547 / 46410
|
||||
50 : 495057205241079648212477525 / 66
|
||||
52 : -801165718135489957347924991853 / 1590
|
||||
54 : 29149963634884862421418123812691 / 798
|
||||
56 : -2479392929313226753685415739663229 / 870
|
||||
58 : 84483613348880041862046775994036021 / 354
|
||||
60 : -1215233140483755572040304994079820246041491 / 56786730
|
||||
Running time: 0.00489444 seconds
|
||||
35
Task/Bernoulli-numbers/Factor/bernoulli-numbers-2.factor
Normal file
35
Task/Bernoulli-numbers/Factor/bernoulli-numbers-2.factor
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
:: bernoulli-numbers ( n -- )
|
||||
n 1 + 0 <array> :> tab
|
||||
1 1 tab set-nth
|
||||
2 n [a,b] [| k |
|
||||
k 1 - dup
|
||||
tab nth *
|
||||
k tab set-nth
|
||||
] each
|
||||
2 n [a,b] [| k |
|
||||
k n [a,b] [| j |
|
||||
j tab nth
|
||||
j k - 2 + *
|
||||
j 1 - tab nth
|
||||
j k - * +
|
||||
j tab set-nth
|
||||
] each
|
||||
] each
|
||||
1 :> s!
|
||||
1 n [a,b] [| k |
|
||||
k 2 * dup
|
||||
2^ dup 1 - *
|
||||
k tab nth
|
||||
swap / *
|
||||
s * k tab set-nth
|
||||
s -1 * s!
|
||||
] each
|
||||
|
||||
0 1 1 "%2d : %d / %d\n" printf
|
||||
1 -1 2 "%2d : %d / %d\n" printf
|
||||
1 n [a,b] [| k |
|
||||
k 2 * k tab nth
|
||||
[ numerator ] [ denominator ] bi
|
||||
"%2d : %d / %d\n" printf
|
||||
] each
|
||||
;
|
||||
3
Task/Bernoulli-numbers/Factor/bernoulli-numbers-3.factor
Normal file
3
Task/Bernoulli-numbers/Factor/bernoulli-numbers-3.factor
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[ 30 bernoulli-numbers ] time
|
||||
...
|
||||
Running time: 0.004331652 seconds
|
||||
Loading…
Add table
Add a link
Reference in a new issue