calculator implemented by recurrence technique