Using basic code I produced a surd engine for Python, with the Prime Factorization code I created earlier. Now I will work on refining the engine to speed up processing for extremely large numbers or surds. (Code Below, Angle Brackets Removed)
#surds #python #primefactoriaztion
def primefactor(ff):
from functools import reduce
factors =[]
dd = 1
gg = ff
div = 2
while not dd == ff:
gg%div
if gg%div != 0: ##Prime Factorization Code for Surds
div+=1 ##By Ralph Turchiano
elif gg%div ==0: ##Rough Code, not commented or w/proper variable Id's yet
factors.append(div)
gg = gg/div
div=2
dd = reduce((lambda a, b: a * b), factors)
return factors
sq = int(input("Constant "))
ff = sq
fact = primefactor(ff)
print(fact)
import collections ##-------------------------Section Here Seperates the Powers
import math as m #From the Constants
powers = []
fact2 =[]
gg=0
a =0
yy=0
zz=0
jj =0
for cou in fact:
powers.append(fact.count(cou))
#54000 Error #36000 Correct #Error List Count #Fix
xxx = collections.Counter(fact)
fact1 = xxx.most_common()
print(fact1)
while gg len(fact1):
b = 1
fact2.append(fact1[a][b])
a +=1
gg+=1
while jj len(fact1):
zzz=1
print(fact1[yy][zz],"**",fact1[yy][zzz],sep="",end=" ")
jj+=1
yy+=1
re = [] #-------------------------------------Reduces the Odd Powers and preps the Constants of odd powers
re1 =[] #To be Multiplied --Ralph Turchiano 18 FEB 2019 (Code Beginer) ;-)#
re2 =[]
re3 =[]
for i in fact:
if i not in re:
re.append(i)
for j in powers:
if j not in re1:
re1.append(j)
for red in fact2:
if red%2 !=0:
re2.append(red)
for redz in fact2:
if redz%2 !=0:
redz = redz-1
re3.append(redz)
else:
re3.append(redz)
print("Raw Prime factors=",fact,"Individual prime Factors=",re,"powers raw=",fact2,"non sqrt to be multiplied=",re2,"perfect squares to be reduce",re3)