init ps6
This commit is contained in:
20
exercises/06/vslc/vsl_programs/ps6-codegen2/euclid.vsl
Normal file
20
exercises/06/vslc/vsl_programs/ps6-codegen2/euclid.vsl
Normal file
@@ -0,0 +1,20 @@
|
||||
func euclid ( a, b )
|
||||
begin
|
||||
if a < 0 then a := -a
|
||||
if b < 0 then b := -b
|
||||
if gcd ( a, b ) > 1 then
|
||||
print "Greatest common divisor of", a, "and", b, "is", gcd ( a, b )
|
||||
else
|
||||
print a, "and", b, "are relative primes"
|
||||
return 0
|
||||
end
|
||||
|
||||
func gcd( a, b )
|
||||
begin
|
||||
var g
|
||||
if b > 0 then
|
||||
g := gcd ( b, a - ((a/b)*b) )
|
||||
else
|
||||
g := a
|
||||
return g
|
||||
end
|
||||
Reference in New Issue
Block a user