Exemple #1
0
 /**
  * 
  * @param integer $doorNumber
  * @return boolean
  */
 public function isDoorClosedWithPrimes($doorNumber)
 {
     $p = new PrimeFactor();
     $primeFactors = $p->getPrimeFactors($doorNumber);
     $primeFactorsCount = array_count_values($primeFactors);
     $numberOfDividers = 1;
     if ($doorNumber != 1) {
         foreach (array_values($primeFactorsCount) as $itemCount) {
             $numberOfDividers *= ++$itemCount;
         }
     }
     return $numberOfDividers % 2 == 0;
 }
 /**
  * @dataProvider primeFactorDataProvider
  */
 public function testPrimeFactors($number, $result)
 {
     $primeFactor = new PrimeFactor();
     $this->assertEquals($result, $primeFactor->getPrimeFactors($number));
 }