1
0
mirror of https://github.com/golang/go synced 2024-11-26 05:17:58 -07:00
go/usr/rsc/gmp/main.go
Russ Cox 75a38963ca cgocall bug fix.
better FFI demo: compute fibonacci numbers using FFI'ed libgmp.

R=r
DELTA=281  (255 added, 19 deleted, 7 changed)
OCL=33815
CL=33820
2009-08-24 21:16:15 -07:00

29 lines
444 B
Go

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import big "gmp"
//import "big"
import "fmt"
func Fib(n int) *big.Int {
a := big.NewInt(0);
b := big.NewInt(1);
for i := 0; i < n; i++ {
a, b = b, a;
b.Add(a, b);
}
return b;
}
func main() {
for i := 0; i <= 100; i++ {
fmt.Println(5*i, Fib(5*i));
}
}