# How to iterate through finite groups

How can I have a collection of all finite groups with order less than a given number? I have tried

```
G = gap.AllSmallGroups(64)
```

However it does not work for other arguments. It instead spits out this [1] error for example for 63 rather than 64. I can tell that this may be a problem with the gap library in sage so I am wondering if there is any other way to do this in sage? I just want to be able to iterate through finite groups less than a given order.

[1]

```
Error in lines 3-4
Traceback (most recent call last):
File "/projects/sage/sage-7.3/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 976, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 2, in <module>
File "/projects/sage/sage-7.3/local/lib/python2.7/site-packages/sage/interfaces/interface.py", line 608, in __call__
return self._parent.function_call(self._name, list(args), kwds)
File "/projects/sage/sage-7.3/local/lib/python2.7/site-packages/sage/interfaces/gap.py", line 921, in function_call
res = self.eval(marker+cmd)
File "/projects/sage/sage-7.3/local/lib/python2.7/site-packages/sage/interfaces/gap.py", line 575, in eval
result = Expect.eval(self, input_line, **kwds)
File "/projects/sage/sage-7.3/local/lib/python2.7/site-packages/sage/interfaces/expect.py", line 1294, in eval
for L in code.split('\n') if L != ''])
File "/projects/sage/sage-7.3/local/lib/python2.7/site-packages/sage/interfaces/gap.py", line 771, in _eval_line
raise RuntimeError(message)
RuntimeError: Gap produced error output
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 2nd choice method found for `RankPGroup' on 1 arguments
executing __SAGE_LAST__:="__SAGE_LAST__";;Rank(\$sage1);;
```

You may find https://ask.sagemath.org/question/286... useful in this regard if you don't actually have the small groups library installed.

To me, the error message hints that one tries to call

`RankPGroup`

on a group which is not a $p$-group. I don't know why SageMath attempts this though.Hmm, it could be a Gap issue. Not sure.

No,

`AllSmallGroups(64);`

in GAP works perfectly fine.Thanks for this feedback. Huh, then someone who knows the GAP interface will have to look into this.