简体   繁体   English

程序陷入了长循环-如何退出?

[英]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) (用于我的rsa解密作业)

I've just started to Python so ı am a beginner and ı didn't understand why this program doesn't work after finding factors. 我刚开始使用Python,所以我是一个初学者,我在发现因素后不理解为什么该程序无法正常工作。

p and q are the factor numbers, ı wrote it manually after program calculated. pq是因子数字,ı是在计算程序后手动编写的。

I want to print totientfonk but I can't. 我想打印totientfonk但不能。 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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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