You can create a geometric progression by setting the first element of the array and defining the factor you want to decrease by in each step. Then loop over the desired number of steps to fill the rest of the array.
Here's an example code:
main.m330 chars19 lines
This will output an array with 10 elements, where each element is half of the previous element. You can adjust the starting element (start
), the factor (fact
), and the length of the array (n
) to fit your specific needs.
gistlibby LogSnag