One possible solution is to first check if a number is prime or not using a helper function. Then, use a loop to go through all the numbers between 1 and some upper limit. For each number, check if it is not prime, and if so, add it to a running sum. Finally, return the total sum.
Here's an example implementation:
main.m616 chars29 lines
You can test the function with different upper limits like this:
main.m71 chars7 lines
gistlibby LogSnag