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.
27 lines
351 B
27 lines
351 B
5 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
"strconv"
|
||
|
)
|
||
|
|
||
5 years ago
|
// Greatest common divisor
|
||
|
func gcd(num1, num2 int) int {
|
||
5 years ago
|
for i := num1; i > 0; i-- {
|
||
|
if num1%i == 0 && num2%i == 0 {
|
||
|
return i
|
||
|
}
|
||
|
}
|
||
|
return 1
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
if len(os.Args) != 3 {
|
||
5 years ago
|
return
|
||
5 years ago
|
}
|
||
|
v1, _ := strconv.Atoi(os.Args[1])
|
||
|
v2, _ := strconv.Atoi(os.Args[2])
|
||
5 years ago
|
fmt.Println(gcd(v1, v2))
|
||
5 years ago
|
}
|