Greatest common divisor: Difference between revisions

Content deleted Content added
→‎{{header|D}}: remove silly solution
Peter (talk | contribs)
added Cobra example
Line 409:
DISPLAY "The gcd is " A
STOP RUN.</lang>
 
=={{header|Cobra}}==
 
<lang cobra>
class Rosetta
def gcd(u as number, v as number) as number
u, v = u.abs, v.abs
while v > 0
u, v = v, u % v
return u
 
def main
print "gcd of [12] and [8] is [.gcd(12, 8)]"
print "gcd of [12] and [-8] is [.gcd(12, -8)]"
print "gcd of [96] and [27] is [.gcd(27, 96)]"
print "gcd of [51] and [34] is [.gcd(34, 51)]"
</lang>
 
Output:
<pre>
gcd of 12 and 8 is 4
gcd of 12 and -8 is 4
gcd of 96 and 27 is 3
gcd of 51 and 34 is 17
</pre>
 
=={{header|CoffeeScript}}==