# Ho to get rid of remainders when performing division operations?

I'm facing this problem in my code where I trying to read a user's input for a division operation displayed on an LCD. I'm interested in using division operations without reminders since it is easier for users to input single digit (or two) instead of a fraction. To do so, I check the reminder between two randomly generated first. If it is zero, I display the equation. If it is not a zero (division operation has a reminder), I pick another two random numbers.

I know that the method that I am using is logically correct, I'm not sure why my code keeps displaying the division operations with reminders! I'm speculating it is probably because I'm using long as a datatype for the randomly generated numbers and the result as well.

Can anyone help me understand this behavior or if anyone has faced this problem before? Here is a snippet of my code where I generate the division.

``````long num1, num2, result;

randomSeed(analogRead(0)); //Generate different numbers
num1 = random(1, 11); // between 1 and 10
num2 = random(1, 11); // between 1 and 10

while (num1%num2 !=0){
num1 = random(1, 11); // between 1 and 10
num2 = random(1, 11); // between 1 and 10
}
result = num1/num2;
``````

I really don't know what is going on because you didn't post your entire sketch. I'm not sure how you could display a remainder when you pick two numbers that don't have one.

The code you posted does not display or output anything.

You'll find helpful hints on posting in the "How to get the best of this forum" sticky, at the head of every forum topic.