Re: Math Question....

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 10:17 AM -0400 4/22/10, Dan Joseph wrote:
On Thu, Apr 22, 2010 at 10:12 AM, Stephen <stephen-d@xxxxxxxxxx> wrote:

 1,252,398 DIV 30 = 41,746 groups of 30.

 1,252,398 MOD 30 = 18 items in last group

Well, the only problem with going that route, is the one group is not
equally sized to the others.  18 is ok for a group in this instance, but if
it was a remainder of only 1 or 2, there would be an issue.  Which is where
I come to looking for a the right method to break it equally.

--
-Dan Joseph


_Dan:

As I see it -- you are asking is "What would be the 'optimum' group size for 1,252,398?"

"Optimum" here meaning:

1. A group size of 30 or under;
2. All groups being of equal size.

Is that correct?

There may not be an exact solution, but a first order attempt would be to divide the total number by 30 and check the remainder (i.e., MOD), the do the same for 29, 28, 27... and so on.

The group size "solution" would be a number with a zero remainder OR with a remainder closest to your group size.

That would be my first blush solution.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux