Coprimes: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 859: | Line 859: | ||
{{out}} |
{{out}} |
||
<pre>{False, True, False, True, False}</pre> |
<pre>{False, True, False, True, False}</pre> |
||
=={{header|MATLAB}}== |
|||
<syntaxhighlight lang="matlab">disp(coprime([21, 17, 36, 18, 60], [15, 23, 12, 29, 15])); |
|||
function coprimes = coprime(a,b) |
|||
coprimes = cell(1,numel(a)); |
|||
for i = 1:numel(a) |
|||
if gcd(a(i),b(i)) == 1 |
|||
coprimes{i}(1) = a(i); |
|||
coprimes{i}(2) = b(i); |
|||
end |
|||
end |
|||
not_coprimes = cellfun('isempty',coprimes); |
|||
coprimes(not_coprimes) = []; |
|||
end</syntaxhighlight> |
|||
{{out}} |
|||
<pre>{[17 23]} {[18 29]}</pre> |
|||
=={{header|Nim}}== |
=={{header|Nim}}== |