A smart card is a general computing device that is Turing complete; basically it is a system-on-a-chip (SoC) with a limited amount of inputs / output. So in principle you can calculate anything with a smart card.
BigInteger
(bignum) arithmetic however is tricky on such small processors. Many smart cards are 16 or even 8 bit computing devices (although 32-bit ARM is making some inroads even there). This is problematic for large number calculations such as multiplication and division. Addition can be easily implemented on any CPU of course - it is very easy to extend 8 or 16 bit additions to an N bit addition for any large N.
For this reason, many smart cards contain a coprocessor that contains a Montgomery multiplier, which is mainly used to perform asymmetric cryptography such as RSA and ECC (Elliptic Curve) calculations. The availability of this coprocessor for general purpose calculations depends on the operating system. Java Card for instance contains an optional bignum interface, but this interface is not often implemented.
With these kind of calculations it is likely that you need low level access to the coprocessor. If you want to keep A and B secret then you also need to keep side channel analysis - DPA and sharks with lasers: LFI) in mind, so if you want to perform the calculations yourself you're in danger.
The inputs and outputs can be performed using the normal APDU interface, which is the default for almost any smart card. You may need extended length or chained APDU's though, if your input or output values are large enough (255 bytes is the default maximum input, 256 bytes the default maximum output).
How you program the smart card depends on the operating system on the smart card. Java Card + Global Platform is the default for most manufacturer independent applications, but it has a relatively high level API (often extended with proprietary API's).