11 lines
304 B
Factor
11 lines
304 B
Factor
! Copyright (c) 2007 Samuel Tardieu
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
USING: kernel math math.functions sequences fry ;
|
|
IN: math.algebra
|
|
|
|
: chinese-remainder ( aseq nseq -- x )
|
|
dup product
|
|
[
|
|
'[ _ over / [ swap gcd drop ] keep * * ] 2map sum
|
|
] keep rem ; foldable
|