Ans and memory (Calculator)

Add ans, the last successful result (Error: no previous answer before any). Memory buttons: M+ adds ans to memory, M- subtracts it, MR recalls (and makes memory the new ans), MC clears; each prints M = <memory. Memory starts at 0.

Input: Expressions and memory commands, one per line.

Output: One line per input line.

Difficulty: Medium. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.

Hint

  • ans only changes after an expression succeeds.

More Calculator practice