Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How do I store a function's results for repeated calls?

In Mathematica one can do this:

factors[n_] := factors[n] = FactorInteger[n]

Then, the first time you call factors[2^385-1], the result is computed, stored, and returned. Next time you make the call, no computation is needed, and the result is returned immediately. How do I do this in Sage?