Nothing
##
## c h i n e s e .R
##
chinese <- function(a, m) {
stopifnot(is.numeric(a), is.numeric(m))
if (any(floor(m) != ceiling(m)) || any(m < 1) ||
any(floor(a) != ceiling(a)))
stop("Arguments 'a', 'm' must be vectors of integers resp. natural numbers.")
n <- length(m)
if (length(a) != n)
stop("Arguments 'a' an 'm' must be vectors of equal length.")
for (i in 1:(n-1)) {
for (j in (i+1):n) {
if (GCD(m[i], m[j]) > 1) {
stop("Elements in argument 'm' must be pairwise coprime.")
}
}
}
M <- prod(m)
x <- 0
for (i in 1:n) {
Mmi <- prod(m[-i]) # or: Mmi <- M/m[i]
mmi <- modinv(Mmi, m[i])
x <- x + a[i] * Mmi * mmi
}
return(x %% M)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.