Jump to content

Greatest common divisor: Difference between revisions

m
m (→‎{{header|Simula}}: Fixed {{out}})
m (→‎{{header|AWK}}: portability)
Line 299:
=={{header|AWK}}==
The following scriptlet defines the gcd() function, then reads pairs of numbers from stdin, and reports their gcd on stdout.
<lang awk>$ awk 'funcfunction gcd(p,q){return(q?gcd(q,(p%q)):p)}{print gcd($1,$2)}'
12 16
4
Line 306:
45 67
1</lang>
 
 
=={{header|Axe}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.