Generating division problems with integer results

  • Thread starter Thread starter Grep
  • Start date Start date
  • Tags Tags
    Division Integer
AI Thread Summary
The discussion focuses on generating division problems with integer results for a mental arithmetic application. The user is exploring how to set minimum and maximum values for the dividend and divisor while ensuring that the generated problems yield valid integer results. There are considerations about excluding trivial results and the feasibility of implementing fixed-point arithmetic in the future. The user acknowledges that speed is not currently an issue and is leaning towards coding a solution that checks divisibility, despite potential inefficiencies. The conversation also touches on the need for icons for the application and the possibility of using open-source resources for that purpose.
Grep
Messages
298
Reaction score
3
I'm not sure at all how best to approach this problem. Basically, the application is for practicing mental arithmetic. Most of the features are pretty easy, with the exception of division, which is the topic here.

I accept a minimum and maximum for the first and last numbers in the division. I haven't gotten to decimal points and fixed point yet. There will be a checkbox for "Integer results only", which would be my default until I implement fixed point. And that adds a wrinkle in for which I've not found a graceful answer.

Keep in mind the configuration values for the problem generation are open to change, so if that makes it much easier, that's a possibility. Possibly, not providing min/max for both values in the division might make it easier.

Given the allowed ranges for the first and last values of the division, I need to first make sure those values work. It's quite possible to enter values which means there are no possible integer results. For example, firstMin=3, firstMax=5, lastMin=3, lastMax=5. Clearly, nothing between 5 and 3 is divisible by any number between 5 and 3.

Beyond that, I'm not sure what the best way is to generate these numbers. Roots with integer results were so much easier. I can't think of a way without checking divisibility of the first number by every possible second number. Not sure it's even possible.

Any thoughts? Opinions greatly appreciated! I'd like to move on to implementing fixed point, state saving and graphs.
 
Technology news on Phys.org
I can't think of a way without checking divisibility of the first number by every possible second number.
What's wrong with this solution? Have you actually coded it up and found that you really need something faster?
 
Hurkyl said:
What's wrong with this solution? Have you actually coded it up and found that you really need something faster?

heh I suppose you're probably right. In theory, I want to make sure it scales up to fairly large numbers, but it's not like I'm about to care about factorizing truly large numbers. So perhaps time won't be a factor.

I may as well code it up that way and see how well it works. Extra time should be negligible for value ranges most people would ever try. The more I think about it, the more I realize you're probably right.

Not sure if I can get around storing the list of possible divisors from which I pick if I want to choose one randomly, but also probably not a huge problem for values people are likely to want to use.

Thanks for the comment!
 
For the record, it's easier to choose quotient and divisor than it is to choose dividend and divisor. And you can get some mileage out of interval arithmetic -- e.g. you can compute the largest and smallest quotients that can be produced by dividing numbers in the two intervals you supplied.

Also, why do the given intervals have to be on the dividend and divisor? :wink:


P.S. your example allows 4/4=1.
 
Hurkyl said:
For the record, it's easier to choose quotient and divisor than it is to choose dividend and divisor. ...

That's what I would do; generate a pair of random integers, find their product and display it.
 
Hurkyl said:
For the record, it's easier to choose quotient and divisor than it is to choose dividend and divisor. And you can get some mileage out of interval arithmetic -- e.g. you can compute the largest and smallest quotients that can be produced by dividing numbers in the two intervals you supplied.

Also, why do the given intervals have to be on the dividend and divisor? :wink:

Yeah, I wish I could do that. But given what the app does, it's much more logical, I think, for the user to set the min/max range of the dividend and divisor. Certainly more logical when "Integer results only" is disabled. It also matches what is done in the other modules for addition, subtraction, etc.

I did implement it yesterday, and it works fine. Speed isn't an issue so far. Probably won't be.

Hurkyl said:
P.S. your example allows 4/4=1.

True, I exclude that for the obvious reason that it's totally trivial (I don't even go past half the dividend since after that, the number can't possibly divide it except in the trivial case). I may add a checkbox for "Exclude trivial results", but that might be overkill. I see no reason anyone would ever want that kind of division problem. Let's just say that if you need to practice them, you need more than a little practice at mental arithmetic. Like a new brain.

It's probably about time I started on implementing decimal points and fixed point math. Would be nice to release this thing before the end of the year. :smile: I admit, it's pretty useful as it is now, though. Now if only I knew someone who could make me some nice icons for the toolbar for free...

Thanks folks!
 
Grep said:
Now if only I knew someone who could make me some nice icons for the toolbar for free...

Is it open source? If it is, there is an excessively large selection. If not, there's still non-viral /permissive licenses like CC-BY, LGPL, BSD, and public domain that allow you to use their icons with your [proprietary] program, with conditions(like requiring attribution).

This page has quite a few links you may be able to use. http://openiconlibrary.sourceforge.net/LICENSES.html
 
Last edited by a moderator:
TylerH said:
Is it open source? If it is, there is an excessively large selection. If not, there's still non-viral /permissive licenses like CC-BY, LGPL, BSD, and public domain that allow you to use their icons with your [proprietary] program, with conditions(like requiring attribution).

This page has quite a few links you may be able to use. http://openiconlibrary.sourceforge.net/LICENSES.html

Thanks TylerH. I looked on that site previously and hadn't found anything that would work. And I'm not sure which license I'll go for either, so that's a problem. Great site though, thanks!
 
Last edited by a moderator:

Similar threads

Replies
21
Views
6K
Replies
16
Views
2K
Replies
17
Views
1K
Replies
47
Views
6K
Replies
2
Views
2K
Replies
12
Views
2K
Back
Top