Skip to content

Instantly share code, notes, and snippets.

Created May 1, 2012 13:06
Show Gist options
  • Save anonymous/2567793 to your computer and use it in GitHub Desktop.
Save anonymous/2567793 to your computer and use it in GitHub Desktop.
euler 20
<?php
set_time_limit(120);
//error_reporting(0);
$n = nfact(100);
function nfact($x)
{
$result = 1;
if($x >1){
for($i=2;$i<=$x;$i++){
$result *= $i;
}
}
return $result;
}
$n = number_format($n,0,'.','');
$a = str_split($n);
echo array_sum($a);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment