summaryrefslogtreecommitdiff
path: root/tests/mime-detection/example_mime.sage
blob: 958557498a2e2a9fa63426fdfba1707d976a80cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
@cached_function
def test(n):
    """
    An arbitrary recursion, with caching.

    EXAMPLES::

        sage: [test(i) for i in range(7)]
	[1, 1, 4/3, 5/3, 61/27, 86/27, 10687/2187]
    """
    if n == 0 or n == 1:
        return 1
    else:
        return test(n - 1) + test(n - 2)^2 / 3