urbit/pub/docs/dev/hoon/library/3ba.md

68 lines
1.2 KiB
Markdown
Raw Normal View History

2015-02-18 06:03:21 +03:00
section 3bA, lite number theory
===============================
2015-08-12 00:32:57 +03:00
### `++fu`
2015-02-18 06:03:21 +03:00
++ fu :: modulo (mul p q)
|= a=[p=@ q=@]
=+ b=?:(=([0 0] a) 0 (~(inv fo p.a) (~(sit fo p.a) q.a)))
|%
XX document
2015-08-12 00:32:57 +03:00
### `++dif`
2015-02-18 06:03:21 +03:00
++ dif
|= [c=[@ @] d=[@ @]]
[(~(dif fo p.a) -.c -.d) (~(dif fo q.a) +.c +.d)]
::
XX document
2015-08-12 00:32:57 +03:00
### `++exp`
2015-02-18 06:03:21 +03:00
++ exp
|= [c=@ d=[@ @]]
:- (~(exp fo p.a) (mod c (dec p.a)) -.d)
(~(exp fo q.a) (mod c (dec q.a)) +.d)
::
XX document
2015-08-12 00:32:57 +03:00
### `++out`
2015-02-18 06:03:21 +03:00
++ out :: garner's formula
|= c=[@ @]
%+ add
+.c
(mul q.a (~(pro fo p.a) b (~(dif fo p.a) -.c (~(sit fo p.a) +.c))))
::
XX document
2015-08-12 00:32:57 +03:00
### `++pro`
2015-02-18 06:03:21 +03:00
++ pro
|= [c=[@ @] d=[@ @]]
[(~(pro fo p.a) -.c -.d) (~(pro fo q.a) +.c +.d)]
::
XX document
2015-08-12 00:32:57 +03:00
### `++sum`
2015-02-18 06:03:21 +03:00
++ sum
|= [c=[@ @] d=[@ @]]
[(~(sum fo p.a) -.c -.d) (~(sum fo q.a) +.c +.d)]
::
XX document
2015-08-12 00:32:57 +03:00
### `++sit`
2015-02-18 06:03:21 +03:00
++ sit
|= c=@
[(mod c p.a) (mod c q.a)]
XX document