Sujet : Re: exercise in double number arithmetic
De : mhx (at) *nospam* iae.nl (mhx)
Groupes : comp.lang.forthDate : 07. Jul 2024, 17:45:19
Autres entêtes
Organisation : novaBBS
Message-ID : <5676491fd2f5898dc1393d87486aec77@www.novabbs.com>
References : 1 2 3 4
User-Agent : Rocksolid Light
On Sun, 7 Jul 2024 16:13:33 (UTC), Ahmed wrote:
On Sun, 7 Jul 2024 15:41:54 (UTC), mhx wrote:
[..]
2 \ For N M return "N OVER M " (N/M)
3 : CHS >R R@ - 1 R> 1+ 1 ?DO OVER I + I */ LOOP NIP ;
[..]
table.calc
>
table 68 N * 34 + 2* cells + 2@ d. 28453041475240576740 ok
>
Wolfram alpha gives C(68,43) = 28453041475240576740
>
>
minforth version gives: 68 34 bcoef 28453041475240574976 ok (it is
different)
Interesting! I don't immediately see where that goes wrong...
FORTH> : test 67 1 do i i 2/ CHS CR I . dup H. space . loop ;
FORTH> test
1 $00000001 1
2 $00000002 2
3 $00000003 3
4 $00000006 6
5 $0000000A 10
6 $00000014 20
7 $00000023 35
8 $00000046 70
9 $0000007E 126
10 $000000FC 252
11 $000001CE 462
12 $0000039C 924
13 $000006B4 1716
14 $00000D68 3432
15 $00001923 6435
16 $00003246 12870
17 $00005EF6 24310
18 $0000BDEC 48620
19 $000168DA 92378
20 $0002D1B4 184756
21 $000561CC 352716
22 $000AC398 705432
23 $0014A18E 1352078
24 $0029431C 2704156
25 $004F59AC 5200300
26 $009EB358 10400600
27 $013210BC 20058300
28 $02642178 40116600
29 $049F73E8 77558760
30 $093EE7D0 155117520
31 $11E9E123 300540195
32 $23D3C246 601080390
33 $458C00A6 1166803110
34 $8B18014C 2333606220
35 $000000010E75C9A2 4537567650
36 $000000021CEB9344 9075135300
37 $000000041D5EF65C 17672631900
38 $000000083ABDECB8 35345263800
39 $000000100C258D9A 68923264410
40 $00000020184B1B34 137846528820
41 $0000003EA955AF04 269128937220
42 $0000007D52AB5E08 538257874440
43 $000000F4F3092084 1052049481860
44 $000001E9E6124108 2104098963720
45 $000003BE7F5B5DD8 4116715363800
46 $0000077CFEB6BBB0 8233430727600
47 $00000EAA1D7B2F8E 16123801841550
48 $00001D543AF65F1C 32247603683100
49 $0000397C21A572BC 63205303218876
50 $000072F8434AE578 126410606437752
51 $0000E18483FF3844 247959266474052
52 $0001C30907FE7088 495918532948104
53 $0003755D946EB6F8 973469712824056
54 $0006EABB28DD6DF0 1946939425648112
55 $000D9638C720AA3C 3824345300380220
56 $001B2C718E415478 7648690600760440
57 $0035690281893C18 15033633249770520
58 $006AD20503127830 30067266499541040
59 $00D2148152D785F8 59132290782430712
60 $01A42902A5AF0BF0 118264581564861424
61 $033AC44F881661D0 232714176627630544
62 $0675889F102CC3A0 465428353255261088
63 $0CB764F927D82123 916312070471295267
64 $196EC9F24FB04246 1832624140942590534
65 $321847F48D727306 3609714217008132870
66 $64308FE91AE4E60C 7219428434016265740 ok
( higher gives integer divide by 0 )
-marcel