Coprimes: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add BQN) |
(Added solution for Action!) |
||
Line 147: | Line 147: | ||
<pre>17 23 |
<pre>17 23 |
||
18 29</pre> |
18 29</pre> |
||
=={{header|Action!}}== |
|||
<lang Action!>INT FUNC Gcd(INT a,b) |
|||
INT tmp |
|||
IF a<b THEN |
|||
tmp=a a=b b=tmp |
|||
FI |
|||
WHILE b#0 |
|||
DO |
|||
tmp=a MOD b |
|||
a=b b=tmp |
|||
OD |
|||
RETURN (a) |
|||
PROC Test(INT a,b) |
|||
CHAR ARRAY s0="not ",s1="",s |
|||
IF Gcd(a,b)=1 THEN |
|||
s=s1 |
|||
ELSE |
|||
s=s0 |
|||
FI |
|||
PrintF("%I and %I are %Scoprimes%E",a,b,s) |
|||
RETURN |
|||
PROC Main() |
|||
Test(21,15) |
|||
Test(17,23) |
|||
Test(36,12) |
|||
Test(18,29) |
|||
Test(60,15) |
|||
RETURN</lang> |
|||
{{out}} |
|||
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Coprimes.png Screenshot from Atari 8-bit computer] |
|||
<pre> |
|||
21 and 15 are not coprimes |
|||
17 and 23 are coprimes |
|||
36 and 12 are not coprimes |
|||
18 and 29 are coprimes |
|||
60 and 15 are not coprimes |
|||
</pre> |
|||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |
||
<lang algol68>BEGIN # test the coprime-ness of some number pairs # |
<lang algol68>BEGIN # test the coprime-ness of some number pairs # |