def nonZeroDigits(x, n, g): if((x<=0)|(n<2)): return [] li=[] while(x>0): d=divmod(x, n) if(d[1]!=0): li.append(d[1]**g) x=d[0] li.sort() return li; def nonZeroFactorDigits(x, n, g): if((x<=0)|(n<2)): return [] li=[] f=list(factor(x)) #ensures inequality of nonZeroFactorDigits(x, n, g) and nonZeroDigits(x, n, g) if x is prime if((len(f)==1)&(f[0][1]==1)): return []; for c in range(len(f)): for d in range(f[c][1]): ld=nonZeroDigits(f[c][0], n, g) li+=ld li.sort() return li; #the actual function def smithClass(x, n, g): d=nonZeroDigits(x,n,g) f=nonZeroFactorDigits(x,n,g) if((x<=0)|(n<2)): return 0 if(d==f): return 2 if(sum(d)==sum(f)): return 1 else: return 0; #this variable affects the order degree=1 #this variable affects the radix radix=10 c=2 index=1 while(index<=10000): #change this line from >=1 to ==2 if you want to check only for A176670 like terms #you may also want to set the degree to 1 for max efficiency #change this line from >=1 to ==1 if you want to exclude A176670 like terms if(smithClass(c,radix,degree)>=1): print(str(index)+" "+str(c)) index+=1 c+=1 print("complete")