Hi Marc,
I would like to encourage you (and everyone else) to post entire pg files (not just code snippets) along with webwork version information, which can be found at the bottom of every webwork page and looks like this:
Page generated at 06/06/2014 at 11:02am EDT
The first time you define $A, it is in the Numeric context. When $A next appeared, you tried to coerce $A into the LimitedNumeric context. I have a hunch that you should have used only the LimitedNumeric context and never used the Numeric context. Further, you should have done your arithmetic using Perl objects and then promoted a Perl object to a MathObject only when necessary.
The scalars $a and $b are Perl objects (not MathObjects) and so they can be added together to get another Perl object. When $a and $b are added to give a Perl object, the LimitedNumeric context should not complain, since it only concerns itself with MathObjects.
Try:
### begin code ############################
Context("LimitedNumeric");
$a = random(1,5,1);
$b = random(1,5,1);
# Pre-compute the answer $c as a Perl object.
# Addition is allowed since $a and $b are Perl objects, not MathObjects.
$c = $a + $b; # so $c is a Perl object, not a MathObject
# Define a MathObject $C with the same value as the Perl object $c.
$C = Compute($c); # $C is a MathObject in the LimitedNumeric context
# The rest of your code probably works just fine as long as you use
# $C as the answer.
### end code ##############################
Best regards,
Paul Pearson