# Measuring infinite loops [closed]

Theoretically, is there a way to measure how many infinite loops are running at a given point in time? In other words, is there a way to freeze everything and get a number on how many infinite lines of code are running on every machine.

• I'm not sure how to make sense of this question. – Yuval Filmus Oct 5 '18 at 7:27
• Maybe I worded it wrong. When you execute a program, some type of loop runs right? I was wondering if there is a way to basically see how many programs are running at once across all devices connected to the internet. I am sure it is in the trillions but I was just curious. – Cody Rutscher Oct 5 '18 at 8:52

While I don't think your question is fitting for cs.StackExchange, let me try to answer it anyway:

You would approach this problem as follows:

1. To answer how many infinite loops run on all devices, you would need to determine the number of infinite loop on each device
2. To determine the number of infinite loops on each device, you would have to count all loops running on each device and then determine if they will be running forever
3. The last step would require a method that determines for a given loop if it will run forever. Assuming you had such a method, you could do the following:

a.) Take any piece of code, $$\Pi$$

b.) Put it into a loop of the form: "$$\text{do} \{\ \Pi\ \}\ \text{while}\ (false);$$" As the resulting expression is a loop, you could feed it to your loop-decision method to find out if it terminates.

c.) The loop will terminate, if and only if $$\Pi$$ terminates. As you can take any $$\Pi$$ you want, you would thus be able to solve the Halting problem, which is proven to be impossible.

PS: I think the correct label would be computability-theory, not complexity-theory. The latter deals with computations that need a finite time and approaches to derive boundaries for that finite time.

• Please. If you think the question is off-topic, don't answer it. If we answer off-topic questions, there's no point having a topic at all. – David Richerby Oct 5 '18 at 10:33
• I have the impression that my answer answers the question and that my answer is more or less the standard procedure for a computability proof, a topic related to CS. If I had to guess, I would assume that a person with no prior knowledge/child would formulate a question like this when exposed to some basic computability theory. So I thought I'd include some pointers to relevant wiki articles for getting acquainted. – oerpli Oct 5 '18 at 10:43
• I certainly agree that your answer contains computer science. :-) – David Richerby Oct 5 '18 at 12:21