Prime decomposition: Difference between revisions
Content added Content deleted
mNo edit summary |
(PascalABC.NET) |
||
Line 4,277: | Line 4,277: | ||
readln; |
readln; |
||
end.</syntaxhighlight> |
end.</syntaxhighlight> |
||
=={{header|PascalABC.NET}}== |
|||
<syntaxhighlight lang="delphi"> |
|||
function Factors(N: BigInteger): List<BigInteger>; |
|||
begin |
|||
var lst := new List<BigInteger>; |
|||
if N = 1 then |
|||
lst.Add(N); |
|||
var i := 2bi; |
|||
while i * i <= N do |
|||
begin |
|||
while N mod i = 0 do |
|||
begin |
|||
lst.Add(i); |
|||
N := N div i; |
|||
end; |
|||
i += 1; |
|||
end; |
|||
if N >= 2 then |
|||
lst.Add(N); |
|||
Result := lst; |
|||
end; |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
[71,839,1471,6857] |
|||
</pre> |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |