Prime factorization in pascal as a function/procedure
<p>I have to build a prime factorization program with pascal using a function or procedure.
I think I am on a pretty good path, but my problem at the moment is, that it seems to be impossible to assign a dynamic relay as the ouput of a function/procedure. And I have no real clue what I could use or do instead (except a string, but that feels just not right at all).</p>

<pre><code>PROCEDURE PrimFac(n: INTEGER; VAR res: array of INTEGER);

VAR
    divisor, a, counter: INTEGER;
    b: array of INTEGER;

BEGIN
    divisor := 2;
    a := n;
    counter := 0;
    WHILE divisor &lt;= n DIV 2 DO BEGIN
        IF a MOD divisor = 0 THEN BEGIN
            a := a DIV divisor;
            counter := counter + 1;
            SetLength(b, counter);
            b[counter] := divisor;
        END
        ELSE
            divisor := divisor + 1;
    END;
    res := b
END;

BEGIN
WriteLn(PrimFac(210));
END.
</code></pre>

<p>Any help or hint would be highly appreciated. (:
Thank you very much in advance
-Florian</p>