An algorithm is a finite set of rules specifying sequences of computational steps for solving a given problem, with the following five properties.
- Finiteness. An algorithm must always terminate after a finite number of steps.
- Definiteness. Each step of an algorithm must be precisely defined, that is, the actions to be carried out must be rigorously and unambiguously specified.
- Input. An algorithm has zero or more inputs, given before the algorithm begins or during the algorithm's execution.
- Output. An algorithm has one or more outputs, which relate to the inputs.
- Effectiveness. Every operation of an algorithm must be sufficiently rudimentary, such that in principle, the operation can be done by a human using paper and pencil, in finite time.