本文介绍了我该如何检查,如果一个程序终止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可用于确定此一般规则?例如:
INT I = 10;
而(ⅰ→1){
如果(ⅰ%2 == 0)I = I / 2;
别的我= 3 * I - 1;
}
解决方案
这是停机问题。不存在一种算法能够做到你的要求的。
在具体地,如果有这样的算法,则考拉兹猜想时,在你的问题相关的功能,将是微不足道的(或至少是一个容易得多)。
Is there a general rule that can be used to determine this? E.g:
int i = 10;
while (i > 1 ) {
if (i%2 == 0) i = i/2;
else i = 3*i - 1;
}
解决方案
This is the halting problem. There does not exist an algorithm capable of doing what you ask.
In particular, if there was such an algorithm, then the collatz conjecture, related to the function in your question, would be trivial (or at least a lot easier).
这篇关于我该如何检查,如果一个程序终止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!