summaryrefslogtreecommitdiff
path: root/gcd.go
diff options
context:
space:
mode:
authorIvan Krasin <imkrasin@gmail.com>2012-03-30 21:11:50 +0000
committerIvan Krasin <imkrasin@gmail.com>2012-03-30 21:11:50 +0000
commit15f2c46559bf98cc10327cfc33d292fe1be5213a (patch)
tree726674fc5d36aab88d797fabee7e80c87a127a86 /gcd.go
parent562f33073053f92e5d1995a9b2b16057d03210b3 (diff)
downloadgcd-15f2c46559bf98cc10327cfc33d292fe1be5213a.tar.gz
gcd.go: update to Go1. Use uint64 instead of uint, because strconv.ParseUint returns uint64, and there's no reason to artificially limit the tool to uint (which is now 32 bits)
Diffstat (limited to 'gcd.go')
-rw-r--r--gcd.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/gcd.go b/gcd.go
index 429c22e..2b2bd3d 100644
--- a/gcd.go
+++ b/gcd.go
@@ -23,7 +23,7 @@ import "fmt"
import "flag"
import "strconv"
-func gcd2(a, b uint) uint {
+func gcd2(a, b uint64) uint64 {
if b == 0 {
return a
}
@@ -34,8 +34,8 @@ func gcd2(a, b uint) uint {
return gcd2(b, a%b)
}
-func gcdn(ns []uint) uint {
- var r uint // zero by default
+func gcdn(ns []uint64) uint64 {
+ var r uint64 // zero by default
for i := range ns {
r = gcd2(r, ns[i])
}
@@ -46,12 +46,12 @@ func main() {
flag.Parse() // without this 6g will give flag.NArg() = 0 next (WTF?)
n := flag.NArg()
if n > 0 {
- ns := make([]uint, n) // We have garbage collector!
+ ns := make([]uint64, n) // We have garbage collector!
// Or: for i := range ns, since range of ns is equal to flag.NArg()
for i := 0; i < n; i++ {
// Drop the second return value (error code):
- ns[i], _ = strconv.Atoui(flag.Arg(i))
+ ns[i], _ = strconv.ParseUint(flag.Arg(i), 0, 64)
}
g := gcdn(ns)