Skip to content

Instantly share code, notes, and snippets.

@olexandr-konovalov
Created October 22, 2018 23:01
Show Gist options
  • Save olexandr-konovalov/23bc8398349b64c67de85542bedd307d to your computer and use it in GitHub Desktop.
Save olexandr-konovalov/23bc8398349b64c67de85542bedd307d to your computer and use it in GitHub Desktop.
Ordering of finite groups by the sum of orders of their elements
# Code for https://math.stackexchange.com/q/2933753/
TestOneOrder:=function(n)
# find the smallest example among the groups of order n
local s,i,m,d,x;
# Calculate lists of sums of element orders.
# Avoid using AllSmallGroups(n) which potentially may be very large
s := List([1..NrSmallGroups(n)],i->Sum(List(SmallGroup(n,i),Order)));
if Length(Set(s))=NrSmallGroups(n) then
# Sum of element orders uniquely defines each group
return fail;
else
# There are duplicates - find them first
d := Filtered( Collected(s), x -> x[2] > 1 );
# Find the minimal possible value of the sum of element orders
m := Minimum( List( d, x-> x[1] ) );
# Find positions of m in the list
# Return the list of group IDs
return List( Positions(s,m), x -> [n,x] );
fi;
end;
FindSmallestPair:=function(n)
# check all groups of order up to n
local i, res;
for i in [1..n] do
# \r at the end of the print returns to the beginning of the line
Print("Checking groups of order ", i, "\r");
res := TestOneOrder(i);
if res<>fail then
# print new line before displaying the output
Print("\n");
return res;
fi;
od;
return fail;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment