[GAP Forum] Elementary

tkohl at math.bu.edu tkohl at math.bu.edu
Thu Jan 21 16:09:49 GMT 2021


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
> 



More information about the Forum mailing list