All pastes #333017 Raw Edit

Mine

public php v1 · immutable
#333017 ·published 2007-01-30 16:48 UTC
rendered paste body
<?php/*145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.Find the sum of all numbers which are equal to the sum of the factorial of their digits.Note: as 1! = 1 and 2! = 2 are not sums they are not included.*/     function factorial($n)        {           if($n>1 AND $n != 2) {return $n*factorial($n-1);       } elseif($n == 2)          {              return 2;              } else                {                return 1;                 }         }      for($int=3;$int < 3000000;$int++)          {            $sum=0;            $inta = str_split($int);            foreach($inta as $asd)               {                 $a = factorial($asd);                 $sum = $a+$sum;               }               if($sum == $int)                  {                     $ca++;                     echo("<br>Numberr: ".$int." count: ".$ca);                  }           }?>