arithmetic calculator without recursion