<script>
factorial=1;
num=prompt("Type number:", "");
for(a=num;a>1;a--){
factorial = factorial * a;
}
document.write("<h1><br><center>" + num + "!=" + factorial);
</script>
mpz_class factorial(mpz_class num)
{
mpz_class tot(num--);
while(num != 0)
{
tot *= num--;
}
return tot;
}
function factorial(num)
{
fact=1;
for(a=num;a>1;a--){
fact = fact * a;
}
return fact
}
#!/usr/bin/perl
print "Enter an integer number: \n";
$Number = <STDIN>;
for ($n = ($Number-1) ; $n >1; $n -=1) {
$Number *= $n; }
print "The factorial of that number is: $Number\n";
<?php
$factorial="1";
$n=1000;
for($i=1; $i<=$n; ++$i) $factorial=bcmul($factorial, $i);
echo $factorial;
?>
acskurucz wrote:
- Code: Select all
<?php
$factorial="1";
$n=1000;
for($i=1; $i<=$n; ++$i) $factorial=bcmul($factorial, $i);
echo $factorial;
?>
It can handle very very very big numbers.
Return to Interpreted Languages
Users browsing this forum: No registered users and 0 guests