# execution is killed for unknown reason

The following code defines a function `num_classes(n)`

and easily computes it for $n=1,2,3,4,5$ in Sage 9.7rc0. However, for $n=6$ its computation after some time is being killed by the system without any apparent reason. I expect that $n=6$ will run some hours, but there is no single reason for it to be killed. In particular, it cannot be a memory issue (unless it's a memory leak of some kind) as the code essentially iterates over elements generated on-fly and saves the smallest ones into the set `res`

. It does not create any big data structures and the set `res`

cannot contain at most $n!$ ($=720$ for $n=6$) elements by design. How to figure out what goes wrong here?

```
import itertools
def num_classes(n):
P = PolynomialRing(ZZ,n,'x')
x = P.gens()
res = set()
for s in itertools.product( *(range(k) for k in (2..n)) ):
f = [x[0],1-x[0]]
for k,i in enumerate(s):
f[i:i+1] = [f[i]*x[k+1], f[i]*(1-x[k+1])]
g = min( sorted(map(lambda z: z.subs(dict(zip(y,t))),f)) for t in itertools.product( *((xi,1-xi) for xi in x) ) for y in Permutations(x) )
res.add( tuple(g) )
return len(res)
```

Could you please provide an estimation of the time you had to wait until the computation is killed so that people that want to reproduce know how much they have to wait ?

On a different system with Sage 9.7.rc1 the answer was successfully produced within 5 hours. But I'm still wonder what to do in such a situation to debug the reason.