From: "Jo�o C�ndido de Souza Neto" on
there�s an error in the forget the former:

for ($g = $maxpergroup; $g > 0; $g--) {
if ($items mod $g <> 0) continue;
$Groups = $items div $g;
}


""Jo�o C�ndido de Souza Neto"" <joao(a)consultorweb.cnt.br> escreveu na
mensagem news:87.84.21218.63C50DB4(a)pb1.pair.com...
> for ($g = $maxpergroup; $g > 0; $g++) {
> if ($items mod $g <> 0) continue;
> $Groups = $items div $g;
> }
>
> Maybe it can helps you.
>
> "Dan Joseph" <dmjoseph(a)gmail.com> escreveu na mensagem
> news:q2oa20394491004220707x980cef5ej2b310c97d123056b(a)mail.gmail.com...
>> Howdy,
>>
>> This is a math question, but I'm doing the code in PHP, and have expunged
>> all resources... hoping someone can guide me here. For some reason, I
>> can't
>> figure this out.
>>
>> I want to take a group of items, and divide them into equal groups based
>> on
>> a max per group. Example.
>>
>> 1,252,398 -- divide into equal groups with only 30 items per group max.
>>
>> Can anyone guide me towards an algorithm or formula name to solve this?
>> PHP
>> code or Math stuff is fine. Either way...
>>
>> Thanks...
>>
>> --
>> -Dan Joseph
>>
>> www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.
>> Promo
>> Code "NEWTHINGS" for 10% off initial order
>>
>> http://www.facebook.com/canishosting
>> http://www.facebook.com/originalpoetry
>>
>
>


From: "Jo�o C�ndido de Souza Neto" on
I think today is not may day to write. hehehe

sorry.
""Jo�o C�ndido de Souza Neto"" <joao(a)consultorweb.cnt.br> escreveu na
mensagem news:12.B5.21218.F0D50DB4(a)pb1.pair.com...
> there�s an error in the forget the former:
>
> for ($g = $maxpergroup; $g > 0; $g--) {
> if ($items mod $g <> 0) continue;
> $Groups = $items div $g;
> }
>
>
> ""Jo�o C�ndido de Souza Neto"" <joao(a)consultorweb.cnt.br> escreveu na
> mensagem news:87.84.21218.63C50DB4(a)pb1.pair.com...
>> for ($g = $maxpergroup; $g > 0; $g++) {
>> if ($items mod $g <> 0) continue;
>> $Groups = $items div $g;
>> }
>>
>> Maybe it can helps you.
>>
>> "Dan Joseph" <dmjoseph(a)gmail.com> escreveu na mensagem
>> news:q2oa20394491004220707x980cef5ej2b310c97d123056b(a)mail.gmail.com...
>>> Howdy,
>>>
>>> This is a math question, but I'm doing the code in PHP, and have
>>> expunged
>>> all resources... hoping someone can guide me here. For some reason, I
>>> can't
>>> figure this out.
>>>
>>> I want to take a group of items, and divide them into equal groups based
>>> on
>>> a max per group. Example.
>>>
>>> 1,252,398 -- divide into equal groups with only 30 items per group max.
>>>
>>> Can anyone guide me towards an algorithm or formula name to solve this?
>>> PHP
>>> code or Math stuff is fine. Either way...
>>>
>>> Thanks...
>>>
>>> --
>>> -Dan Joseph
>>>
>>> www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.
>>> Promo
>>> Code "NEWTHINGS" for 10% off initial order
>>>
>>> http://www.facebook.com/canishosting
>>> http://www.facebook.com/originalpoetry
>>>
>>
>>
>
>


From: Richard Quadling on
On 22 April 2010 15:13, Ashley Sheridan <ash(a)ashleysheridan.co.uk> wrote:
> On Thu, 2010-04-22 at 10:17 -0400, Dan Joseph wrote:
>
>> On Thu, Apr 22, 2010 at 10:12 AM, Stephen <stephen-d(a)rogers.com> 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.
>>
>
>
> How do you mean break it equally? If the number doesn't fit, then you've
> got a remainder, and no math is going to change that. How do you want
> that remainder distributed?
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

It sounds like you are looking for factors.

http://www.algebra.com/algebra/homework/divisibility/factor-any-number-1.solver

Solution by Find factors of any number

1252398 is NOT a prime number: 1252398 = 2 * 3 * 7 * 29819
Work Shown

1252398 is divisible by 2: 1252398 = 626199 * 2.
626199 is divisible by 3: 626199 = 208733 * 3.
208733 is divisible by 7: 208733 = 29819 * 7.
29819 is not divisible by anything.

So 29819 by 42 (7*3*2)

would be a route.


Take note of http://www.algebra.com/algebra/homework/divisibility/Prime_factorization_algorithm.wikipedia,
which has the comment ...

"Many cryptographic protocols are based on the difficultly of
factoring large composite integers or a related problem, the RSA
problem. An algorithm which efficiently factors an arbitrary integer
would render RSA-based public-key cryptography insecure.".




--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling
From: Richard Quadling on
On 22 April 2010 15:26, Richard Quadling <rquadling(a)googlemail.com> wrote:
> On 22 April 2010 15:13, Ashley Sheridan <ash(a)ashleysheridan.co.uk> wrote:
>> On Thu, 2010-04-22 at 10:17 -0400, Dan Joseph wrote:
>>
>>> On Thu, Apr 22, 2010 at 10:12 AM, Stephen <stephen-d(a)rogers.com> 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.
>>>
>>
>>
>> How do you mean break it equally? If the number doesn't fit, then you've
>> got a remainder, and no math is going to change that. How do you want
>> that remainder distributed?
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>>
>
> It sounds like you are looking for factors.
>
> http://www.algebra.com/algebra/homework/divisibility/factor-any-number-1.solver
>
> Solution by Find factors of any number
>
> 1252398 is NOT a prime number: 1252398 = 2 * 3 * 7 * 29819
> Work Shown
>
> 1252398 is divisible by 2: 1252398 = 626199 * 2.
> 626199 is divisible by 3: 626199 = 208733 * 3.
> 208733 is divisible by 7: 208733 = 29819 * 7.
> 29819 is not divisible by anything.
>
> So 29819 by 42 (7*3*2)
>
> would be a route.
>
>
> Take note of http://www.algebra.com/algebra/homework/divisibility/Prime_factorization_algorithm.wikipedia,
> which has the comment ...
>
> "Many cryptographic protocols are based on the difficultly of
> factoring large composite integers or a related problem, the RSA
> problem. An algorithm which efficiently factors an arbitrary integer
> would render RSA-based public-key cryptography insecure.".
>
>
>
>
> --
> -----
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>

Aha. Missed the "30" bit.

So, having found the factors, you would need to process them to find
the largest combination under 30.

2*3
2*3*7
2*7
3*7

are the possibilities (ignoring any number over 30).

Of which 3*7 is the largest.

So, 1,252,398 divided by 21 = 59,638


Is that the sort of thing you are looking for?

--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling
From: "Jason" on
-----Original Message-----
From: Ashley Sheridan [mailto:ash(a)ashleysheridan.co.uk]
Sent: 22 April 2010 15:13
To: Dan Joseph
Cc: PHP eMail List
Subject: Re: [PHP] Math Question....

On Thu, 2010-04-22 at 10:17 -0400, Dan Joseph wrote:

> On Thu, Apr 22, 2010 at 10:12 AM, Stephen <stephen-d(a)rogers.com> 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.
>
>
>
>How do you mean break it equally? If the number doesn't fit, then you've
>got a remainder, and no math is going to change that. How do you want
>that remainder distributed?
>
>Thanks,
>Ash
>http://www.ashleysheridan.co.uk
>
>
>

Perhaps a round-robin approach is called for?

<?
$items=1252398;
$groupsize=30;

for ($i=0;$i<$items;$i++)
$grouparray[$i % $groupsize][]=$i;


print_r($grouparray);
?>

HTH
J