News for hackers. Stuff that matters.
Re:Computer History Museum 2018 Fellow: Guido van Rossum by analog31 on Thursday February 22, 2018 @08:16AM (#16437311)
To be fair, here's plain English (from Wikipedia, re-entered by me):

The sequence f(n) of Fibonacci numbers is defined by the recurrence relation:

f(n) = f(n-1) + f(n-2),

with seed values

f(0) = 0 and f(1) = 1

And a possible variant in Python:

    f = [0, 1]
    for i in range(100):
        f.append(f[-1] + f[-2])
Re:Computer History Museum 2018 Fellow: Guido van Rossum by joshuamorton on Thursday February 22, 2018 @12:15PM (#16439193)
heck, if you really want that:

    @functools.lru_cache
    def fibs(n):
        if n == 0:
            return 0
        elif n == 1:
            return 1
        else:
            return fibs(n-1) + fibs(n-2)
Technically you could also write it as

    def f(n):
        if n in {0, 1}:
            return n
        return f(n-1) + f(n-2)
which is a bit trickier, but arguably better matches the way the seed values are described in english.