Solved ProjectEuler\020: php, ruby

This commit is contained in:
FuryFire
2012-03-09 13:56:02 +01:00
parent e689e807da
commit 36c31696a9
3 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,15 @@
<?php
define('FACTORIAL',100);
function factorial($num) {
if($num == 0)
return 1;
else
return bcmul($num,factorial(bcsub($num,1)));
}
$sum = 0;
$fac = factorial(FACTORIAL);
for($c = 0; $c < strlen($fac); $c++) {
$sum += $fac[$c];
}
echo $sum;