News flash: I'm going to Australia in February, so this Web site may be switched off at any time.
Suppose you need to compute the factorial function, N! = 1 * 2 * ... * N. Here's a complete Icon program containing a procedure that computes the factorial function, and a main program that prints all the values up to 4:
procedure main ( ) every n := 1 to 4 do write ( n, "! = ", Factorial ( n ) ); end procedure Factorial ( k ) # Returns k! = 1*2*...*k result := 1; # Prepare to compute product every result *:= ( 1 to k ); # Multiply by 1, 2, ..., k return result; endThe first few lines of the output look like this:
1! = 1 2! = 2 3! = 6 4! = 24
john@nmt.edu