[GAP Forum] coprime to n

Bill Allombert Bill.Allombert at math.u-bordeaux.fr
Sat Feb 11 17:01:43 GMT 2017


On Sat, Feb 11, 2017 at 10:11:55PM +0530, Surinder Kaur wrote:
> Hi all
> 
> We know that the Euler-totient function in GAP is Phi(n) . But how one can
> list all the integers co-prime to a given integer n.

Just use Filtered:

gap> n:=100;Filtered([1..n-1],x->Gcd(x,n)=1);
100
[ 1, 3, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39, 41, 43,
47, 49, 51, 53, 57, 59, 61, 63, 67, 69, 71, 73, 77, 79, 81, 83, 87, 89,
91, 93, 97, 99 ]

Cheers,
Bill.



More information about the Forum mailing list