Handbook
Glossary
chinese-remainder ( aseq nseq -- x )
Vocabulary
math
.
algebra
Inputs
aseq
a sequence of integers
nseq
a sequence of positive integers
Outputs
x
an
integer
Word description
If
nseq
integers are pairwise coprimes,
x
is the smallest positive integer congruent to each element in
aseq
modulo the corresponding element in
nseq
.
Definition
USING:
kernel
math
sequences
;
IN:
math.algebra
:
chinese-remainder
( aseq nseq -- x )
dup
product
[
[
over
/
[
swap
gcd
drop
]
keep
*
*
]
curry
2map
sum
]
keep
rem
;
foldable
flushable