2012-11-18 12:50:09 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
2012-11-18 13:06:50 +00:00
|
|
|
import (
|
2012-12-20 02:10:56 +00:00
|
|
|
"github.com/meatballhat/box-o-sand/algs4/go/algs4"
|
2012-11-18 13:06:50 +00:00
|
|
|
)
|
2012-11-18 12:50:09 +00:00
|
|
|
|
2012-11-18 13:06:50 +00:00
|
|
|
const USAGE string = `Usage: algs4-gcd <uint> <uint>`
|
2012-11-18 12:50:09 +00:00
|
|
|
|
|
|
|
func main() {
|
|
|
|
if len(os.Args) < 3 {
|
|
|
|
fmt.Println(USAGE)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
p, err := strconv.ParseUint(os.Args[1], 10, 0)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Wherps: ", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
q, err := strconv.ParseUint(os.Args[2], 10, 0)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Wherps: ", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2012-11-18 13:06:50 +00:00
|
|
|
fmt.Println(algs4.Gcd(p, q))
|
2012-11-18 12:50:09 +00:00
|
|
|
}
|