What about working division backwards: The routine generates the desired
*result* and computes the required problem to get that result.

Is the answer is: 6 remainder 2

Generate random divisor, say '7'.

Computer dividend = 7*6+2 = 44

State problem as: "What's 44 / 7 ?"

-Josh



On Wed, Sep 20, 2017 at 12:37 PM, John R. Hogerhuis <[email protected]>
wrote:

>
> On Wed, Sep 20, 2017 at 8:58 AM Roger Mullins <[email protected]> wrote:
>
>> Ah.  I see where you're headed with that now.  I like that.  Remainders
>> aren't verboten, though. :-) But at the same time that could be a neat
>> feature to incorporate especially on the 'easy' or 'medium' difficulty
>> setting.  Regardless it's starting to look like the best thing to do might
>> be for the division module to have its own dedicated random number
>> subroutine, rather than recycling the one used in the other three parts of
>> the program.
>>
>>
> Yeah for division maybe your basis is a subroutine that you pass a minimum
> and a maximum and gives you an integer within the range.  Call it once for
> a.
> 1-20.  Call it again for c, passing a as the lower bound. a through a+100.
> Problem for the user is to find b and remainder r.
>
> You could use that one random number routine for everything.
>
> Since you're allowing remainders you don't have to worry about the "evenly
> divisible" stuff.
>
> -- John
>

Reply via email to