I have a problem with this python37 code during printing and I would like it not to print out beyond the 3rd print statement of the loop. The program is super fast for a factorization program if I can only have a number (print_factors(f)) to print just below the 4th output when needed.
For example 3 prints like this:
The factors of 3 are: 1, 3
If I input 2047 it prints like this:
The factors of 2047 are: 1, 23, 89, 2047
However I would just like it to show up to 89. Here is the code:
You can get some points if you answer this at stackexchange:
https://stackoverflow.com/questions/5922...-3rd-outpu
For example 3 prints like this:
The factors of 3 are: 1, 3
If I input 2047 it prints like this:
The factors of 2047 are: 1, 23, 89, 2047
However I would just like it to show up to 89. Here is the code:
You can get some points if you answer this at stackexchange:
https://stackoverflow.com/questions/5922...-3rd-outpu
import math
while True:
def print_factors(x):
print("The factors of",x,"are:")
for i in range(1,x+1):
if x % i == 0:
print(i)
p = int(input('Enter a prime number and if the output is 1 and itself its prime: '))
k = ((p**2*2))
l = (((pow(2, k + 1, 2 * k) - 1) % (2 * k)))
f = (k//2//p)
print_factors(f)
