473,386 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Dividing whole numbers problem

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
2 6358
> 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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: muser | last post by:
Can anyone run this program through their compiler or if they can see a logical error please point it out. I have my tutor working on it at the moment but I would rather a less ambigious response...
5
by: M. Akkerman | last post by:
Hi, I've been working on this problem for a while now but I just can't seem to find a good solution for it. Here is the situation. I have the following class class TBigNumber {
5
by: Hasanain F. Esmail | last post by:
I have spent many hours to solve this problem but no result yet. Your help will highly be appriciated. Problem: Let us say I have two field named as number1 and number2 There are 12 pcs of an...
3
by: Neils Christoffersen | last post by:
Hey all, I wrote on Friday asking for some help moving a common subclass field up to the base class (original post and followup included below). This entails storing whole numbers inside float...
9
by: Alberto | last post by:
Eh unfortunately Google groups does not provide any longer a way to reply to the group for older posts (though the one I am referring to is not older than one month), and I happen to come back to...
5
by: John | last post by:
Which variable type (c#) can whole the largest whole number? I know this sounds silly but as double and decimal are made for numbers with decimals I am not sure. Also if anybody knows of any...
5
by: Randeh | last post by:
Simple bubbling sort algorithm, nothing fancy, just trying to find a way to validate each number value as it's entered without creating several arrays and loops using isdigit(). I need to validate...
2
by: meggahertz | last post by:
Hello Everyone! I need help with dividing a list of numbers in to groups of numbers that have constant difference between them. This constant number does not change it remains the same . e.g. 1000...
1
by: Odeh Naber | last post by:
Greetings all! I have a report in which I have seven columns: Column 1: Day number (i.e. Day 1, Day 2, Day 3, etc.). Column 2: SalesCost for that day. Column 3: SalesCost to-date (running sum...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.