1

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.

user3195446
  • 147
  • 1
  • 13

1 Answers1

1

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" );
user3195446
  • 147
  • 1
  • 13
  • This code can be used in the GAP command line. If you need to put it into a function, the syntax is explained in the [GAP Carpentries-style lesson](https://carpentries-incubator.github.io/gap-lesson/03-func/index.html) and in the [GAP Tutorial](https://www.gap-system.org/Manuals/doc/tut/chap4.html). – Olexandr Konovalov Jul 14 '20 at 21:29