Padovan n-step number sequences: Difference between revisions

m
Line 1,069:
# nStepPadovan :: Int -> [Int]
def nStepPadovan(n):
'''Non-finite series of N-step FibonacciPadovan numbers,
defined by a recurrence relation.
'''
def relation(xs):
return xs[0], xs[1:] + [sum(take(n)(xs))]
 
return unfoldr(
relationrecurrence(n)
)(
take(1 + n)(
Line 1,082 ⟶ 1,079:
)
)
 
 
# recurrence :: Int -> [Int] -> Int
def recurrence(n):
'''Recurrence relation in Fibonacci and related series.
'''
def relationgo(xs):
return xs[0], xs[1:] + [sum(take(n)(xs))]
return go
 
 
9,655

edits