In their 1977 work "The Early Development of Programming Languages", Trabb Pardo and Knuth introduced a trivial program which involved arrays, indexing, mathematical functions, subroutines, I/O, conditionals and iteration. They then wrote implementations of the algorithm in several early programming languages to show how such concepts were expressed.
ask for 11 numbers to be read into a sequence Sreverse sequence Sfor eachitemin sequence Scall a function to do an operation
The algorithm reads eleven numbers from an input device, stores them in an array, and then processes them in reverse order, applying a user-defined function to each value and reporting either the value of the function or a message to the effect that the value has exceeded some threshold.
begin integer i; real y; real array a[0:10];
real procedure f(t); real t; value t;
f := sqrt(abs(t)) + 5*t^3;
for i := 0 step 1 until 10 do read(a[i]);
for i := 10 step -1 until 0 dobegin y := f(a[i]);
if y > 400 then write(i, "TOO LARGE")
The problem with the usually specified function is that the term 5*t^3 gives overflows in almost all languages for very large negative values.