superloach / goeis

Go implementation of OEIS sequences.
MIT License
2 stars 0 forks source link

Fix A000008 #3

Closed superloach closed 4 years ago

superloach commented 4 years ago

https://oeis.org/A000008

Current solution is failing tests:

--- FAIL: TestA000008Next (0.00s)
    a000008_test.go:32: x should be 1, got 3
    a000008_test.go:32: x should be 2, got 9
    a000008_test.go:32: x should be 2, got 32
    a000008_test.go:32: x should be 3, got 120
    a000008_test.go:32: x should be 4, got 473
    a000008_test.go:32: x should be 5, got 1925
    a000008_test.go:32: x should be 6, got 8034
    a000008_test.go:32: x should be 7, got 34188
    a000008_test.go:32: x should be 8, got 147789
--- FAIL: TestA000008Reset (0.00s)
    a000008_test.go:55: x should be 1, got 11
FAIL
FAIL    github.com/superloach/goeis     0.008s
FAIL
superloach commented 4 years ago

http://oeis.org/A187243/a187243_1.pdf

var Seq = func(n int) (int, error) {
        q := n / 10
        a := float64(q+1) * (math.Round(float64((n+4)*(n+4))/20) - ((1 / float64(6)) * float64(q) * float64(3*n+10*q+7)))

        return int(a), nil
}

could use some cleaning up, but this works