Jacobsthal numbers: Difference between revisions
Content added Content deleted
Line 1,319: | Line 1,319: | ||
'''Infinite sequence of terms of OEIS A001045 |
'''Infinite sequence of terms of OEIS A001045 |
||
''' |
''' |
||
return jacobsthalish(0, 1) |
return jacobsthalish([0, 1]) |
||
# jacobsthalish :: (Int, Int) -> [Int] |
# jacobsthalish :: (Int, Int) -> [Int] |
||
def jacobsthalish( |
def jacobsthalish(xs): |
||
'''Infinite sequence of jacobsthal-type series |
'''Infinite sequence of jacobsthal-type series |
||
beginning with a, b |
beginning with a, b |
||
''' |
''' |
||
def go( |
def go(ys): |
||
a, *t = |
a, *t = ys |
||
return a, t + [2 * a + t[0]] |
return a, t + [2 * a + t[0]] |
||
return unfoldr(go)( |
return unfoldr(go)(xs) |
||
Line 1,347: | Line 1,347: | ||
( |
( |
||
'Jacobsthal-Lucas numbers', |
'Jacobsthal-Lucas numbers', |
||
30, jacobsthalish(2, 1) |
30, jacobsthalish([2, 1]) |
||
), |
), |
||
( |
( |