Dear Fawad Hayat, from you description it is not really clear what you want to compute; nor does your pseudo code snippet make much sense to me.
> On 27. Jul 2020, at 05:53, Fawad Hayat <fawadhaya...@gmail.com> wrote: > > Hello everbody, > > I’m writing a program in GAP for group elements, that any two elements of a > group G are an integral power of one another, i.e., for any x, y ∈ G, then x > n=y or yn=x, where n is any positive integer. If you really just want to check for a given group G whether \forall x,y\in G \exists n>0: x^n=y or y^n=x Then you don't need to write length GAP programs for this: You can easily characterize these groups by hand: they certainly must be cyclic; now you just need to check which cyclic groups satisfy this property (I'll leave it to you to figure out which exactly, it's a fun exercise). Or perhaps you really want to compute something else; then you should try to carefully write up what it is you really are asking, mathematically, so that we have a chance of understanding and helping. Best regards Max Horn > But it has some problems. *I > don’t know where to write the value “n.”* I’ll be very grateful if it can > be written more simply. > > > > f := f unction(G) > > local x; y; M; MM; i; j; s; d; n; > > M:= []; MM:= []; s:= 0; d:= []; > > *for n in Integers do* > > for x in Elements(G) do > > for y in Elements(G) do > > if x^n = y then > > Add(M; 1); > > else > > Add(M; 0); > > fi; > > od; > > od; > > Add(MM;M); M := []; > > od; > > Print(MM); > > for i in MM do > > for j in i do > > s:= s + j; > > od; > > Add(d; s); s := 0; > > od; > > Print(d); > > return; > > end; > _______________________________________________ > Forum mailing list > Forum@gap-system.org > https://mail.gap-system.org/mailman/listinfo/forum _______________________________________________ Forum mailing list Forum@gap-system.org https://mail.gap-system.org/mailman/listinfo/forum