Ask Your Question

Ajat's profile - activity

2013-12-06 12:09:05 +0200 received badge  Famous Question (source)
2013-03-26 11:54:46 +0200 received badge  Notable Question (source)
2012-12-29 07:05:07 +0200 received badge  Popular Question (source)
2012-03-20 13:04:42 +0200 commented answer How to define a recursive sequence on Sage?

oh my, thanks :)

2012-03-20 12:48:12 +0200 asked a question How to define a recursive sequence on Sage?

Hi, can someone tell me how to define a recurrence relation? I've tried this

def a(n):
if n==1:
        return 1
        else
              return a(n-1)+1/a(n-1)^2

It gives the following error:

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "_sage_input_10.py", line 10, in <module>
        exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZGVmIGEobik6CiAgICBpZiBuPT0xOgogICAgICAgIHJldHVybiAxCiAgICAgICAgZWxzZQogICAgICAgIHJldHVybiBhKG4tMSkrMS9hKG4tMSleMg=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
      File "", line 1, in <module>

  File "/private/var/folders/u5/u5DFi45LFQ4s8DR+4Sy8NE+++TI/-Tmp-/tmpaYysvY/___code___.py", line 6
    else
       ^
SyntaxError: invalid syntax

thanks before.