home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 9,200 of 10,840   
   Rick Rothstein to All   
   Re: Dividing whole numbers problem   
   06 Feb 05 11:10:03   
   
   From: rickNOSPAMnews@NOSPAMcomcast.net   
      
   > 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   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca