mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
351 B
26 lines
351 B
package main |
|
|
|
import ( |
|
"fmt" |
|
"os" |
|
"strconv" |
|
) |
|
|
|
// Greatest common divisor |
|
func gcd(num1, num2 int) int { |
|
for i := num1; i > 0; i-- { |
|
if num1%i == 0 && num2%i == 0 { |
|
return i |
|
} |
|
} |
|
return 1 |
|
} |
|
|
|
func main() { |
|
if len(os.Args) != 3 { |
|
return |
|
} |
|
v1, _ := strconv.Atoi(os.Args[1]) |
|
v2, _ := strconv.Atoi(os.Args[2]) |
|
fmt.Println(gcd(v1, v2)) |
|
}
|
|
|