PYTHON Prime Factors of All Natural Numbers Before The Entered Value
import math
n = int(input("Enter an integer: "))
for i in range(1, n + 1) :
if i == 1:
print("1 = 1")
else :
print(i, "=", end=' ')
c = 0
for j in range(1, i + 1) :
if i % j == 0:
c += 1
if c == 2:
print(i, "(prime)", end = '')
print()
else :
t = i
while t % 2 == 0 :
print("2", end='x')
t = t // 2
k = 3
x = math.ceil(math.sqrt(t)) + 1
while k <= x :
while (t % k == 0) :
print(k, end='x')
t = t // k
k += 2
if t > 2 :
print(t, end='x')
print()