There is an interesting thread in the HP3000-L discussion group on COBOL optimization techniques (obviously results attained are specific to the HP platform, but some general inferences may be drawn). See:
Regards,
Glenn
Regards,
Glenn
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Make a linked list to hold the 'found primes'
add '2' to the linked list (the first prime)
for n = 3 to [i]n[/i] by +2
take square root of [i]n[/i]
loop through the entries in the linked list, dividing into [i]n[/i]
if linked list number > sqrt([i]n[/i]) or remainder = 0
then it's not prime, iterate to next
else
add it to the linked list
end-if