Hi my code takes too long and it does not produce an answer. my code produces the answer for gh in range(104) and range(105) but it take to long for higher ranges.
please could you find out what's wrong with the code, thanks.f
you don't need to read this part,it explains the code. This code is to find the strong Achilles number. In the code I imported all the perfect power and turned them into 0 and go rid of the zero values in the code. I find values that can be divisible by 2 ,3 and 5 without remainder. the code returns s=1/2 if divisible by 2, m=1/3 if divisible by 3 and n=1/5 if divisible by 5. values will be multiplied together to obtain g which is equivalent to φ(tl)value (tl =vl[i], if tl =864, g= φ(tl)= 288). a will be the length of the values of j,k and h, r will elimate all the zero in a. if the minimum value in r is greater than or equal to 2 then hjj = vl[i], ty += [hjj]. TMl = [fj[i] for i, vl_ele in enumerate(vl) if vl_ele in ty] (meaning if vl[i] =864, TMl = 288).
The values of TMl divisible by 2 ,3 and 5 without remainder returns v=1/2 if divisible by 2, p=1/3 if divisible by 3 and c=1/5 if divisible by 5.values will be multiplied together to obtain f which is equivalent to φ(tl)value (tl =vl[i], if tl =864, g= φ(tl)= 288). l will be the length of the values of t,o and c, r will elimate all the zero in l. if the minimum value in u is greater than or equal to 2, tcount = mount and scount +=[tcount]. Scount should be 656 below 10^8
stm = []
FF = []
ty = []
scount= []
from sympy import perfect_power
for gh in range(865):
inj = perfect_power(gh)
#print(i)
if inj== False:
Try= gh
stm += [Try]
else:
Try = 0
stm += [Try]
vl= list(filter(lambda nn: nn!=0,stm))
fj = []
jns = []
vcount = []
for i in range(len(vl)):
tl = vl[i]
# tl = i
h = []
k = []
j = []
rl = []
hq = []
hm = []
ll = 1
remain = 1
s = 0
m=0
n= 0
nw = 0
nt = 0
while tl > 1:
if tl%2 == 0:
remain = tl/2
tl = remain
j += [tl]
s = 1/2
elif tl%3 == 0:
remain = tl/3
tl = remain
k += [tl]
m = 1/3
elif tl%5 == 0:
remain = tl/5
tl = remain
h += [tl]
n = 1/5
#elif tl%7 == 0:
#remain = tl/7
#tl = remain
#hq += [tl]
#nw = 1/7
#elif tl%11 == 0:
#remain = tl/11
#tl = remain
#hm += [tl]
#nt = 1/11
else:
ll = 0
break
g = (((2**(len(j)))*(1-(s)))*((3**(len(k)))*(1-(m))) *(( 5**(len(h)))*(1-(n))) *((7**(len(hq)))*(1-(nw)))*((11**(len(hm)))*(1-(nt))))*ll
print(g)
q = int(round(g))
fj += [q]
TT = list(filter(lambda nn: nn!=0,fj))
a = [len(j)*ll,len(k)*ll,len(h)*ll,len(hq)*ll,len(hm)*ll]
if max(a) > 0:
jn = a
r = list(filter(lambda nn: nn!=0,jn))
#jns += [r]
if min(r) >= 2:
count = 1
rcount = count
vcount +=[rcount]
hjj = vl[i]
ty +=[hjj]
else:
count = 0
rcount = count
vcount += [rcount]
#print(len(vl))
#print(len(fj))
TMl = [fj[i] for i, vl_ele in enumerate(vl) if vl_ele in ty]
#print(TMl)
#print(len(ty))
#print(sum(vcount))
#print(ty)
mtm = []
for gtm in range(len(TMl)):
bnj = perfect_power(TMl[gtm])
#print(i)
if bnj== False:
bry= TMl[gtm]
mtm += [bry]
else:
bry = 0
mtm += [bry]
#print(mtm)
vln= list(filter(lambda nn: nn!=0,mtm))
for i in range(len(vln)):
TM = vln[i]
fp = 1
t = []
o = []
c = []
cp = []
cg = []
v=0
p=0
d=0
nj = 0
ij = 0
while TM>1:
if TM%2 == 0:
rem = TM/2
TM = rem
t += [TM]
v = 1/2
elif TM%3 == 0:
rem = TM/3
TM = rem
o += [TM]
p = 1/3
elif TM%5 == 0:
rem = TM/5
TM = rem
c += [TM]
d = 1/5
#elif tl%7 == 0:
#remain = tl/7
#tl = remain
#cg += [tl]
#nj = 1/7
#elif tl%11 == 0:
#remain = tl/11
#tl = remain
#cp += [tl]
#ij = 1/11
else:
fp = 0
break
#else:
#print('another no')
e = (2**(len(t)) * 3**(len(o)) * 5**(len(c)))*fp#*7**(len(cg))*11**(len(cp)))
f = e*(1-(v))*(1-(p))*(1-(d))#"""*(1-(nj))*(1-(ij))"""
w = int(round(f))
l = [len(t),len(o),len(c),len(cg),len(cp)]
#print(l)
if max(l) > 0:
px = l
u = list(filter(lambda nn: nn!=0,px))
#print(u)
if min(u) >= 2:
mount = 1
tcount = mount
scount +=[tcount]
else:
mount = 0
tcount = mount
scount += [tcount]
print(sum(scount))
Aucun commentaire:
Enregistrer un commentaire