简体   繁体   中英

Program trapped in long loop - how to exit?

I am writing a program that finds two prime factors of a number. (for my rsa decrypting homework)

I've just started to Python so ı am a beginner and ı didn't understand why this program doesn't work after finding factors.

p and q are the factor numbers, ı wrote it manually after program calculated.

I want to print totientfonk but I can't. Program doesn't close by the way. It is just waiting.

nsayisi = 27765438273271

for i in range(2,nsayisi):
    if nsayisi % i == 0:
     print(i)


p = 4812569
q = 5769359

totientfonk = (p-1) * (q-1)

print(totientfonk)

Is this what you're trying to do?

nsayisi = 27765438273271
for p in range(2, nsayisi):
    if nsayisi % p == 0:
        q = nsayisi // p
        break
print(p, q)
totientfonk = (p - 1) * (q - 1)
print(totientfonk)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM