Revision history [back]

Pre-parsing is what happened here! Note that

preparse(fermat(5))


almost certainly will get you something with Integer(5), but the iterator (1..9) only consists of Python ints, and apparently the program never actually explicitly coerces to Sage integers but manages to have int output all the way through. Surprising but you can probably trace it step by step.

If you use srange(1,10) that should work, and maybe even [1..9] would give Sage integers? I can't test this right now as I'm not on a high-power situation and wifi is spotty on the train, but try these solutions.

preparse(fermat(5))

almost certainly will That was wrong. The problem is that fermat(1) ends up doing sum([]) which defaults to the Python summation, not Sage summation, and so you just get you something with Integer(5), but the iterator (1..9) only consists Python result of Python ints, and apparently a sum, which is the program never actually explicitly coerces int zero (as an empty sum). I'm not 100% sure how to Sage integers but manages to have int output all the way through. Surprising fix that but you can probably trace it step by step.could at the very least special-case it. I don't think srange would help here.
If you use srange(1,10) that should work, and maybe even [1..9] would give Sage integers? I can't test this right now as I'm not on a high-power situation and wifi is spotty on the train, but try these solutions.