Hello, how can I set my WPF Application with random generator number for division without residue? I try to create a math game in which the user chooses the math operation he wants to calculate, then he chooses what level he wants. Addition, subtraction and multiplication are not a problem. The problem occurs during division.
I would like to see only numbers that have no remainder after division. I created the code shown below.
I would like to see only single-digit numbers that would be divided and the result must not be with the residue.
firstNumber would be: 1,2,3,4,5,6,7,8,9
secondNumber would be: 1(divides all),2(divides 2,4,6,8),3(divides 3,6,9),4(divides 4,8)
Wouldn't there be a more sophisticated solution?
What I have tried:
int maxValue = 10;
Random number = new Random();
int total = 0;
int firstNumber = number.Next(1, maxValue);
int secondNumber = number.Next(1, maxValue);
if (firstNumber < secondNumber)
secondNumber = number.Next(1, firstNumber);
int residue = (firstNumber % secondNumber);
if (residue != 0)
firstNumber = firstNumber + 1;
total = firstNumber / secondNumber;
I would like the values to be single digits. This code still does not guarantee me without erroneous calculations.
Thank you for any advice