main.m406 chars18 lines
This code defines a function createArray
that takes an argument n
for the size of the array to create. It recursively creates the array of size n-1
, and then computes the next element by dividing the previous element by a factor of 1/2. The function returns the resulting array.
The example usage shows how to create an array of size 5 using this function, and displays the resulting array. The output should be:
main.m47 chars2 lines
gistlibby LogSnag