This Python code is an *perfect number* that I wrote (an *perfect number* is a number whose sum divisible by it is equal to the number itself)

The first question is why that Partition List line does not work on the last line of code

The second question is how to write c # code with maximum execution speed?

perfect number

perfect number.gh (11.4 KB)

import rhinoscriptsyntax as rs

import ghpythonlib.components as gh

```
b=[]
t=[]
a=[]
w=[]
h=[]
for i in range(3,n):
for j in range(2,i+1,1):
if i%j==0:
b.append(i//j)
x.append(i//j)
c=sum(b)
if c==i:
t.append(c)
b=[]
print len(t)
for k in range(0,len(t),1):
v=t[k]
for j in range(2,v+1,1):
if v%j==0:
a.append(v//j)
h.append(v//j)
g=len(h)
w.append(g)
h=[]
m=gh.PartitionList(a,w)
```