# Checking function correctness with random number generator

The problem I have has students multiplying binomials. I tried creating a random number generator to make the binomials and that works, but I am running into an error with how to have it check for correctness. If the student was to just rewrite the binomials into the input it will say it is correct, but I need them to be able to write out their product. I need some help with this

Try using countNumberUsage. It can count how many numbers (not digits) were used in a latex expression/equation, or count a specific number. If you’ve got `x^2+7x+6` you can evaluate (which I assume you did) and

`...and countNumberUsage(inputName,6)=1 and countNumberUsage(inputName,1)=1 and...` (just for extra measure)
`...countNumberUsage(inputName,7)=0`

with an evaluateAt() will ensure that `(x+6)(x+1)` is correct, but the expanded is not. (You might need to get a little creative if you have students who write `1x`.)

Oh yeah, `countNumberUsage(inputName)` would count all numbers used. And, it’s fine to use variables for the numbers being counted.

you’re comment on the evaluateAt() is not correct. It takes any input regardless of how it is written, and it will evaluate it at whatever number you tell it to. So if those outputs after evaluating line up, then the question will be perceived as correct. I’ve used that for hundreds of problems.

If you think the countNumberUsage will work, how would the code look then?

You need the countNumberUsage in addition to the evaluateAt. I gave an example of using countNumberUsage, just didn’t include the evaluateAt. I’ll look at your code and edit soon.

Here. I moved the variables from input32 to the note to help clean up the code. (And after the fact, I realized I reduced your random range for ease of checking in my head, so you may want to change those back.)

The code looks good, and I see what you’re doing. Having setting the correct to when they are equal makes sense. It still is having an issue though. It is not registering correctness. When I multiply the binomials it still says it isnt right, and even when I copy and paste the binomial into the input it doesnt say it is right. My coding skills are’nt good enough to catch where the mistake might be at.