[GAP Forum] Elementary

Stefan Kohl sk239 at st-andrews.ac.uk
Thu Jan 21 22:17:17 GMT 2021


You can do this e.g. with the following function:

f := n -> Filtered(Cartesian([1,3..n-1+(n mod 2)],[1..n]),t->t[2] mod OrderMod(2,t[1]) = 0);

Hope this helps,

    Stefan


________________________________
From: tkohl at math.bu.edu <tkohl at math.bu.edu>
Sent: Thursday, January 21, 2021 5:09 PM
To: lopo apelo kosho <helo_07 at yahoo.com>
Cc: forum at gap-system.org <forum at gap-system.org>
Subject: Re: [GAP Forum] Elementary


Hello,

Here is what I was able to come up with.

gap> n:=12;;Filtered(Cartesian([1..n],[2..n]),v->((2^v[1]-1) mod v[2])=0);

[ [ 2, 3 ], [ 3, 7 ], [ 4, 3 ], [ 4, 5 ], [ 6, 3 ], [ 6, 7 ], [ 6, 9 ], [ 8, 3 ], [ 8, 5 ], [ 9, 7 ], [ 10, 3 ],
  [ 10, 11 ], [ 12, 3 ], [ 12, 5 ], [ 12, 7 ], [ 12, 9 ] ]

Basically, one iterates over ordered pairs in [1..n] x [2..n] where 'b' is the first
coordinate 'v[1]' and 'a' is the second 'v[2]'.

The [2..n] being the second coordinate is to omit the trivial case of 1 dividing 2^b-1.

I make no claims that this is the most efficient solution.

I hope this helps.

 -Tim Kohl


On Thu, 21 Jan 2021, lopo apelo kosho wrote:

> Dear Friends,
> I am searching for non-negative integers a and b  in an interval  [0,n] such that a divides (2^b-1).
> It is supposed to have a-any odd number and b=phi(a). I tried to find those values using GAP (please see below) but it seems that I am doing mistake.
> fun:=function(n) local a,b,t;
> t:=[];
> for a in [1..n] do;
> for b in [1..n ] do;
> if 2^b-1 = 0 mod a
> then Add (t,(a,b));
> fi;
> return t;
> od;
> od;
> end;
>
>
> I will be thankful for any help:.
> Regards
>
> _______________________________________________
> Forum mailing list
> Forum at gap-system.org
> https://mail.gap-system.org/mailman/listinfo/forum
>

_______________________________________________
Forum mailing list
Forum at gap-system.org
https://mail.gap-system.org/mailman/listinfo/forum


More information about the Forum mailing list