mathgap-system

GAP programming: variable assignment and functions


This question is about the GAP and the GAP programming language:

I would like to write code that will compute the following formula:

(n^+1)/GcdInt(n^2+1, 2^(Tau(n^2+1)));

for the first 100,000 integers n.

Here is what I have so far:

f:=function(n);
f:=(n^+1)/GcdInt(n^2+1, 2^(Tau(n^2+1)));
return f;
end;

It is grossly wrong. I cannot find any good sources on writing GAP code that I can understand unfortunately.


Solution

  • I got it:

    for i in [1..100000] do
        Print((i^2+1)/GcdInt(i^2+1,2^Tau(i^2+1)), " ");
    od;
    Print( "\n" );