Cecil Westerhof writes:
> To show why it is often easy, but wrong to use recursive functions I
> wrote the following two Fibonacci functions:
> def fib_ite(n):
> if not type(n) is int:
> raise TypeError(f'Need an integer ({n})')
> if n < 0:
> raise Valu
On Sun, Apr 3, 2022 at 2:46 PM Cecil Westerhof via Python-list <
python-list@python.org> wrote:
> Betty Hollinshead writes:
>
> > "Memoising" is the answer -- see "Python Algorithms" by Magnus Lie
> Hetland.
> > In the mean time, here a simplified version of "memoising" using a dict.
> > This ver
Betty Hollinshead writes:
> "Memoising" is the answer -- see "Python Algorithms" by Magnus Lie Hetland.
> In the mean time, here a simplified version of "memoising" using a dict.
> This version handles pretty large fibonacci numbers!
>
> # fibonacci sequence
> # memoised - but using a simple dict
"Memoising" is the answer -- see "Python Algorithms" by Magnus Lie Hetland.
In the mean time, here a simplified version of "memoising" using a dict.
This version handles pretty large fibonacci numbers!
# fibonacci sequence
# memoised - but using a simple dictionary (see Python Algorithms, p177)
m