<?php function findBestFactors($Value, $GroupSize = INF) { foreach(range(min($GroupSize, ceil(sqrt($Value))), 1) as $Factor) { if (0 == ($Value % $Factor)) { return array($Factor, $Value / $Factor); } } } list($Groups, $Size) = findBestFactors($argv[1], isset($argv[2]) ? $argv[2] : INF); echo "$Groups groups of $Size"; ?> Supply a value and an optional maximum group size. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php