1
0

use uint64 and panic on false numbers

- break piont at
This commit is contained in:
Stephen M. McQuay 2012-08-02 16:58:37 -06:00
parent 7de645a7af
commit 0e29275c30

View File

@ -13,10 +13,10 @@ var usage string = "usage: " + os.Args[0] + " <number of fibs>"
// a function that returns an int.
// from cpython/Doc/build/html/library/functools.html
// [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]
func fibonacci() func() int {
cur_fib := 0
nxt_fib := 0
return func() int {
func fibonacci() func() uint64 {
cur_fib := uint64(0)
nxt_fib := cur_fib
return func() uint64 {
if nxt_fib == 0 {
nxt_fib = 1
return 0
@ -24,6 +24,9 @@ func fibonacci() func() int {
tmp := cur_fib
cur_fib = nxt_fib
nxt_fib += tmp
if nxt_fib < cur_fib {
panic("overfull!!")
}
return cur_fib
}
}