Re: Math Question....

From: Date: Thu, 22 Apr 2010 14:59:34 +0000
Subject: Re: Math Question....
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-304428@lists.php.net to get a copy of this message
On Thu, 22 Apr 2010 10:49:11 -0400 Peter van der Does <pvanderdoes@gmail.com> wrote: > > My take on it: > > $Items=1252398; > $MaxInGroup=30; > for ($x=$MaxInGroup; $x>1;$x--) { > $remainder=$Items % $x; > // Change 17 to the max amount allowed in the last group > if ($remainder == 0 || $remainder >= 17) { // > $groups = (int) ($Items /$x)+1; > echo $groups."\n"; > echo $remainder; > break; > } > } > Bugfixed LOL: $Items=1252398; $MaxInGroup=30; for ($x=$MaxInGroup; $x>1;$x--) { $remainder=$Items % $x; // Change 17 to the max amount allowed in a group if ($remainder == 0 || $remainder >= 17) { $groups = (int) ($Items /$x); if ($remainder > 0 ) { $groups++; } echo $groups."\n"; echo $remainder; break; } } -- Peter van der Does GPG key: E77E8E98 IRC: Ganseki on irc.freenode.net Twitter: @petervanderdoes WordPress Plugin Developer Blog: http://blog.avirtualhome.com Forums: http://forums.avirtualhome.com Twitter: @avhsoftware

« previous php.general (#304428) next »