PythonPrimeFactors

Run Settings
LanguagePython
Language Version
Run Command
import time start = time.time() l = [] class factor: value = 0 count = 1 def factorize(y): l2 = [] while y > 1: for z in l: if y % z == 0: y /= z b = True for f in l2: if f.value == z: f.count += 1 b = False break if b: f2 = factor() f2.value = z l2.append(f2) break return l2 x = 2 #while start + 14 > time.time(): while x < 100: p = True for y in l: if x % y == 0: p = False break if p: l.append(x) print(x, end=" = ") f = factorize(x) if len(f) > 0: fs = [] for fx in f: fx2 = str(fx.value) if fx.count > 1: fx2 += "^" + str(fx.count) fs.append(fx2) print(" * ".join(fs)) x += 1
Editor Settings
Theme
Key bindings
Full width
Lines