Number of groups of Lie Type of order $n$ As a combined math/programming exercise, I want to make a function that takes in a natural number $n$ and returns the number of simple groups of order $n$. From the classification of simple finite groups, every simple finite group is cyclic, alternating, Lie type or sporadic.
So far,

*

*Cyclic is straightforward, since there always is one cyclic group of order $n$.

*Alternating is straightforward, since there is one alternating group of order n if $n=m!/2$ for some $m$, and $0$ otherwise.

*Since there are just $26$ sporadic groups, I can do them case by case. The main challenge of these will be storing the size of the monster as an integer.

But how many are there of Lie type of order $n$? Is there a straightforward formula for calculating this?
As a bonus, if I successfully create this function (takes in $n$ and returns the number of simple groups of order $n$) how could I extend it to a function that takes in a number $n$ and returns the number of groups of order $n$?
 A: The orders of the groups of Lie type are polynomials in the size of the underlying field with the degree depending on the rank. You can find formulas at https://en.wikipedia.org/wiki/List_of_finite_simple_groups
So you could calculate through all series and check which once come up for a given order.
Since there are quite a few series, it will be a bit of a slog to go through all cases. Be aware that the group orders are not monotonous in the field order, e.g. $L_2(128)$ is larger than $L_2(157)$.
You might want to check/compare your results with:
http://www.madore.org/~david/math/simplegroups.html
A: 
As a bonus, if I successfully create this function (takes in n and returns the number of simple groups of order $n$) how could I extend it to a function that takes in a number $n$ and returns the number of groups of order $n$?

This is hopeless, we don't know a simple way to calculate the number of groups of order $n$ even if $n$ is a prime power (in which case the only simple factors are cyclic). It would require you to solve the group extension problem which is quite hard.
To give a concrete example, it's currently not known how many groups there are of order $2^{11}=2048$.
