summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCasey Robinson <casey@rampantmonkey.com>2015-06-15 12:48:29 -0400
committerCasey Robinson <casey@rampantmonkey.com>2015-06-15 12:48:29 -0400
commit523653c19e6ad215bba88a2c5b7abf95b2c0c9f9 (patch)
tree4b6d4374d951469bf03edb918b42e1758b6cfac2
parente0373b3bec157ee05c84f5970854d74c7f330cf0 (diff)
downloadfibgo-bigint-spike.tar.gz
fibgo-bigint-spike.tar.bz2
fibgo-bigint-spike.zip
-rw-r--r--main.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/main.go b/main.go
index 836545d..742e781 100644
--- a/main.go
+++ b/main.go
@@ -3,8 +3,8 @@ package main
import (
"flag"
"fmt"
+ "math/big"
"os"
- "strconv"
)
func main() {
@@ -14,9 +14,9 @@ func main() {
fmt.Printf("n not specified\n")
os.Exit(1)
}
- n, err := strconv.Atoi(flag.Args()[0])
- if err != nil {
- fmt.Printf("invalid value for n: %v\n", err)
+ n, ok := big.NewInt(0).SetString(flag.Args()[0], 10)
+ if !ok {
+ fmt.Printf("invalid value for n\n")
}
flag.Args()
switch *method {
@@ -29,10 +29,10 @@ func main() {
}
}
-func iterative(n int) int {
- a := 0
- b := 1
- for i := 0; i < n; i++ {
+func iterative(n *big.Int) *big.Int {
+ a := big.NewInt(0)
+ b := big.NewInt(0)
+ for i := big.NewInt(0); i < n; i.Add(i, big.NewInt(1)){
a += b
a, b = b, a
}