Factorial: Difference between revisions

Content added Content deleted
(Add SmallBASIC)
(PascalABC.NET)
 
Line 7,856: Line 7,856:
factorial := n*factorial(n-1)
factorial := n*factorial(n-1)
end;</syntaxhighlight>
end;</syntaxhighlight>

=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
function FactIter(n: integer): BigInteger;
begin
Result := 1;
for var i:=2 to n do
Result *= i;
end;

function FactRec(n: integer): BigInteger;
begin
if n = 0 then
Result := 1
else Result := n * FactRec(n - 1);
end;


begin
for var i:=1 to 20 do
Println(i,FactRec(i),FactIter(i));
end.
</syntaxhighlight>
{{out}}
<pre>
8 40320 40320
9 362880 362880
10 3628800 3628800
11 39916800 39916800
12 479001600 479001600
13 6227020800 6227020800
14 87178291200 87178291200
15 1307674368000 1307674368000
16 20922789888000 20922789888000
17 355687428096000 355687428096000
18 6402373705728000 6402373705728000
19 121645100408832000 121645100408832000
20 2432902008176640000 2432902008176640000
</pre>


=={{header|Pebble}}==
=={{header|Pebble}}==