File: example_mime.sage

package info (click to toggle)
shared-mime-info 2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 17,528 kB
  • sloc: ansic: 3,791; xml: 2,177; python: 168; sh: 119; javascript: 113; lisp: 28; cobol: 20; makefile: 14; cs: 13; perl: 11; java: 7; objc: 6; php: 1; vhdl: 1
file content (14 lines) | stat: -rw-r--r-- 290 bytes parent folder | download | duplicates (2)
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