I am new to GAP ( - Groups, Algorithms, Programming - a System for Computational Discrete Algebra).
I want to calculate the length of a cycle $(i_1,i_2,\dots,i_k)\in S_n$. (I want to get $k$ from $(i_1,i_2,\dots,i_k)\in S_n$.)
Please tell me how to calculate the length of a cycle $(i_1,i_2,\dots,i_k)\in S_n$ in GAP?
Length(1,2,3);
didn't work.
Order(1,2,3);
worked.
But is this a right way to calculate the length of a cycle in GAP?
If you have a cycle, then I think that using
Orderwill be the best way. It will use fast implementation from the GAP kernel - as you can see, repeating this calculation a million times takes a bit more than a second:If you have a product of several cycles, then
CycleStructurePermwould be a proper way to get the number of cycles of each length. It's also fast:P.S. Of course, one should be careful when dealing with the identity permutation:
These functions are documented in this manual chapter.