1. Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2009). Introduction to Algorithms (3rd ed.). MIT Press. Chapter 1, Section 1.1, defines an algorithm as "any well-defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values, as output." The example is a procedure.
2. Knuth, D. E. (1997). The Art of Computer Programming, Volume 1: Fundamental Algorithms (3rd ed.). Addison-Wesley Professional. In Section 1.1, Knuth outlines five key features of an algorithm: finiteness, definiteness, input, output, and effectiveness. The provided example meets these criteria.
3. Aho, A. V., Hopcroft, J. E., & Ullman, J. D. (1983). Data Structures and Algorithms. Addison-Wesley. The book's introduction defines an algorithm as "a finite sequence of instructions, each of which has a clear meaning and can be performed with a finite amount of effort in a finite length of time."