By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,387 Members | 1,729 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,387 IT Pros & Developers. It's quick & easy.

Dividing whole numbers problem

P: n/a
I'm building a maths program for year 6 children.

Problem with division - I generate a random number between say 1 and 1000. I
want to generate another random number which when divided by the first
number gives a whole number answer. Any Idea how I could do this? Obviously
generating prime numbers is a bit of a problem as well!

Cheers,

Jack
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
> I'm building a maths program for year 6 children.

Problem with division - I generate a random number between say 1 and 1000. I want to generate another random number which when divided by the first
number gives a whole number answer. Any Idea how I could do this? Obviously generating prime numbers is a bit of a problem as well!


Instead of generating a number and trying to find whole number divisors,
what about generating two numbers whose product is 1000 or less and then
presenting that product and one of the numbers you used in the
multiplication to the child... the other number is the answer. Something
like this should work...

FirstNumber = 1 + Int(50 * Rnd)
MaxForSecondNumber = Int(1000 / FirstNumber)
SecondNumber = 1 + Int(MaxForSecondNumber * Rnd)
Product = FirstNumber * SecondNumber

Of course, this doesn't address the "hardness" value of the division.

Rick - MVP

Jul 17 '05 #2

P: n/a

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:dp********************@comcast.com...
I'm building a maths program for year 6 children.

Problem with division - I generate a random number between say 1 and

1000. I
want to generate another random number which when divided by the first
number gives a whole number answer. Any Idea how I could do this?

Obviously
generating prime numbers is a bit of a problem as well!


Instead of generating a number and trying to find whole number divisors,
what about generating two numbers whose product is 1000 or less and then
presenting that product and one of the numbers you used in the
multiplication to the child... the other number is the answer. Something
like this should work...

FirstNumber = 1 + Int(50 * Rnd)
MaxForSecondNumber = Int(1000 / FirstNumber)
SecondNumber = 1 + Int(MaxForSecondNumber * Rnd)
Product = FirstNumber * SecondNumber

Of course, this doesn't address the "hardness" value of the division.

Rick - MVP


That's clever, thank you very much, it works a treat.

Cheers,

Jack
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.