next up previous contents
Next: Solution Up: Procedures and Modules Previous: Solution

 

Triangular Numbers - Array Valued Function

The numbers 1, 3, 6, 10, 15, 21, ... are called triangular numbers because the number of units in each can be displayed as a triangular pyramid of blobs. The tex2html_wrap_inline3310 , tex2html_wrap_inline3312 is computed from tex2html_wrap_inline3314 . Write an array valued function which takes one argument (N) and returns a vector of the first N triangular numbers.

Make sure to specify the argument INTENT.

Write a test program to demonstrate the function and print out the sequence where N = 23.

Go back to Notes gif




next up previous contents
Next: Solution Up: Procedures and Modules Previous: Solution

©University of Liverpool, 1997
Thu May 29 10:11:26 BST 1997
Not for commercial use.