Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 2
    My guess is that there's no sure way that computer recognizes something as infinite loop. You have to be aware of it as a code engineer. Commented Mar 16, 2012 at 14:01
  • But some intelligent language compiler understand and get you out of the loop if such thing happens. Commented Mar 16, 2012 at 14:03
  • 3
    It's easy, just wait for infinity and see if the program has terminated. Commented Mar 16, 2012 at 14:03
  • While I don't think @amit's response below is logically valid, I also don't think there always exists a way to determine if something will loop indefinitely. For example, you could always construct a function whose limit (for some value of parameters) cannot be calculated except numerically---thus you would have to perform the calculation to tell if some end case would result or not (and thus if the loop would perform one way or another). In special cases, making the determination could be done easily analytically, or by trial of the loop.... Commented Mar 16, 2012 at 15:46