10 lines
303 B
Factor
10 lines
303 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
|