12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package kata_test
- import (
- "testing"
- . "github.com/onsi/ginkgo"
- . "github.com/onsi/gomega"
- . "code.osinet.fr/fgm/codewars/kyu5/product_of_consecutive_fib_numbers"
- )
- func dotest(prod uint64, exp [3]uint64) {
- var ans = ProductFib(prod)
- Expect(ans).To(Equal(exp))
- }
- var _ = Describe("Test Example", func() {
- It("should handle basic cases", func() {
- dotest(4895, [3]uint64{55, 89, 1})
- dotest(5895, [3]uint64{89, 144, 0})
- dotest(229970, [3]uint64{377, 610, 1})
- dotest(74049690, [3]uint64{6765, 10946, 1})
- dotest(84049690, [3]uint64{10946, 17711, 0})
- dotest(193864606, [3]uint64{10946, 17711, 1})
- dotest(427859097160, [3]uint64{514229, 832040, 1})
- dotest(5456077604922913920, [3]uint64{2971215073, 4807526976, 0})
- })
- })
- func TestBinet(t *testing.T) {
- OEIS_A000045 := [...]uint64{
- 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597,
- 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418,
- 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465,
- 14930352, 24157817, 39088169, 63245986, 102334155,
- }
- var n int
- var actual, expected uint64
- for n, expected = range OEIS_A000045 {
- actual = Binet(uint64(n))
- if actual != expected {
- t.Errorf("n: %d, expected: %d, got %d\n", n, expected, actual)
- }
- }
- }
|