Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

use big.Int package instead of uint64s

  • Loading branch information...
commit 41cf564a068c6dfed62fb948c9001fb26d42ecec 1 parent 0320f99
authored October 04, 2011

Showing 1 changed file with 4 additions and 2 deletions. Show diff stats Hide diff stats

  1. 6  fib/fib.go
6  fib/fib.go
... ...
@@ -1,18 +1,20 @@
1 1
 package main
2 2
 
3 3
 import (
  4
+  "big"
4 5
   "fmt"
5 6
 	"http"
6 7
   "strconv"
7 8
 )
8 9
 
9  
-var memoize_fibonnaci = map[int]uint64 { 0: 0, 1: 1, 2: 1 }
  10
+var memoize_fibonnaci = map[int]*big.Int { 0: big.NewInt(0), 1: big.NewInt(1), 2: big.NewInt(1) }
10 11
 
11 12
 func fibonnaci(n int) *big.Int {
  13
+  fib_term := new(big.Int)
12 14
   if n <= (len(memoize_fibonnaci) - 1) {
13 15
     return memoize_fibonnaci[n]
14 16
   }
15  
-  fib_term := fibonnaci(n-2) + fibonnaci(n-1)
  17
+  fib_term.Add(fibonnaci(n-2), fibonnaci(n-1))
16 18
   memoize_fibonnaci[n] = fib_term
17 19
   return fib_term;
18 20
 }

0 notes on commit 41cf564

Please sign in to comment.
Something went wrong with that request. Please try again.