Coprimes: Difference between revisions

Added R. Very short.
(Added 11l)
(Added R. Very short.)
Line 896:
60 and 15 are not coprime.
</pre>
 
=={{header|R}}==
<lang R>factors <- function(n) c(Filter(function(x) n %% x == 0, seq_len(n %/% 2)), n)
isCoprime <- function(p, q) all(intersect(factors(p), factors(q)) == 1)
output <- data.frame(p = c(21, 17, 36, 18, 60), q = c(15, 23, 12, 29, 15))
print(transform(output, "Coprime" = ifelse(mapply(isCoprime, p, q), "Yes", "No")))</lang>
{{out}}
<pre> p q Coprime
1 21 15 No
2 17 23 Yes
3 36 12 No
4 18 29 Yes
5 60 15 No</pre>
 
=={{header|Racket}}==
331

edits