Are there useful programs that don't take inputs such as: A user's keyboard input; an interrupt from a clock; data from another server etc.

A program that computed/printed out predefined data could be turned into a file, right?

  • 7
    How about a program that computes the digits of pi? How about a program intended to compute the answer for some mathematical problems, where the "input" is hard-coded into the program itself (during programming or compilation phase)?
    – rwong
    Mar 11, 2017 at 22:06
  • 11
    The answer is yes(1) :-)
    – Blrfl
    Mar 11, 2017 at 22:07
  • So, is the only example mathematical approximation?
    – Tobi
    Mar 11, 2017 at 22:15
  • A dead man's switch that doesn't require configuration. Well, I guess that would take a timer as input, though you could approximate a timer by sitting in a loop. Really, any program where you hard-wire the input data. Mar 11, 2017 at 22:18
  • 1
    This question was unrightfully placed on hold.
    – Tobi
    Mar 12, 2017 at 17:56

6 Answers 6


One example where such a program can be useful is when the program is much shorter than its output. That means that the program is basically a compressed version of its output.

Some practical use cases:

  • Self-extracting zip files
  • Programs whose output is actually infinite, such as yes(1) which repeatedly outputs "y". (Thanks to blrfl for mentioning this in a comment.)

The theoretical term for this concept (when the output is finite) is Kolmogorov complexity. From Wikipedia:

Consider the following two strings of 32 lowercase letters and digits:



The first string has a short English-language description, namely "ab 16 times", which consists of 11 characters. The second one has no obvious simple description (using the same character set) other than writing down the string itself, which has 32 characters.

More formally, the complexity of a string is the length of the shortest possible description of the string in some fixed universal description language [...].

(Note: This fixed universal description language is usually some Turing-complete programming language.)


Yes, unit tests (at least decently written ones).


To be less glib: There are a lot of different unit test setups but they effectively boil down to the following, the code base under test is treated as a library and your unit tests are essentially one big program that when run prints out something like

Test foo passed
Test bar passed
Test baz failed
Test quux passed

If your unit tests are deterministic (which they generally should be as debugging nondeterministic tests is the worst), this will just be a constant string.

Now once you get into the real world the border's really fuzzy here, but I think the general point that an inputless program is a good way of learning about some other set of source code.

  • I thought unit tests take code as an input, to test?
    – Tobi
    Mar 12, 2017 at 3:06
  • @Tobi, hopefully the edit brings the point out.
    – walpen
    Mar 12, 2017 at 3:51
  • I'm confused; will a unit test not test code you've written, making it an input?
    – Tobi
    Mar 12, 2017 at 4:14
  • 1
    @Tobi well, no ... Unit tests don't read the implementation like an input or environmental resource, they include the implementation during compilation. In order to generate pretty, interactive results, a the test suite usually interacts with the environment (like an IDE or test runner). But, that's optional, really. It could just as easily be a binary that executes on its own and dumps the results to standard out. And in fact, I've cowboyed some test runners of that nature myself...
    – svidgen
    Mar 12, 2017 at 10:11

Lots of system utilities. The shutdown, reboot, poweroff commands.

There are others I can't think of right now, I'm sure.


Programs like this occasionally arise and are useful such as to answer a specific question by performing some calculations. But once the program works correctly and produces the result, there is no need to run it anymore.

As an example, I once wrote such a program to produce a set of matrices that convert Euler angles to an orthogonal matrix for all the possible Euler angle systems. The input was essentially generated within the program (a set of permutations). The program symbolically multiplied 3 or 2 matrices together for each possible Euler angle system and produced a TeX file with the resulting matrices. It was less work and less error-prone to write the program than to do the math by hand. There was no input from the environment, though. You just ran the command and it wrote out the file. And once I was satisfied that it was working correctly, I haven't run it again since.


Depends what you mean by redundant. Here are a few I could think of in a couple minutes:

  • A program that creates music or art

  • A program that dances, or sends instructions to a robot that dances

  • A program that models a virtual society and outputs its likely lifespan under varying conditions

  • A radio beacon

Are any of those things redundant?

  • All of those things will have input, even if it's coming from a random seed.
    – RubberDuck
    Mar 12, 2017 at 0:23
  • #1: What do mean "creates music or art"? Randomly = Seeded by an input #2: That would be an input into an interpreter that controls the robotic movement. #3: An inputted society or a randomly generated one? The latter would be seeded #4: What do you mean by "radio beacon"?..
    – Tobi
    Mar 12, 2017 at 0:32
  • Incorrect; none of the items I listed require input, as in, something traversing from outside the system to inside the system. And I don't know where you got the idea that randomness is a requirement for any of it.
    – John Wu
    Mar 12, 2017 at 1:25
  • #1 I mean literally composes a piece of music or draws a picture. It doesn't have to be very good music or a very interesting picture. Neither randomness nor originality is a requirement. #2. No, it would be an output to an interpreter that controls the robotic movement. #3. Neither; a society that determines itself, starting with a basic initial condition, then evolving. #4. A continual transmission in the electromagnetic spectrum, modulated by the output of our program, potentially in accordance with a predetermined pattern.
    – John Wu
    Mar 12, 2017 at 1:47
  • Many novelties and children's toys have no input; when powered, they carry out (often repeat) a pre-determined sequence until the power is disconnected or runs down. A music box probably wouldn't count as a "program" for this question, but a toy dog or robot could easily have a microprocessor simply because it's easier than the discrete components Sep 12, 2022 at 8:35

A program which computes the sequence of prime numbers.

  • A program that calculates the number of primes less than 10^k for 1 <= k <= 30. There’s no chance to get the numbers without running a rather clever program for a substantial time on a large number of computers.
    – gnasher729
    Sep 11, 2022 at 16:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.