10-09-2005 09:35 AM - edited 10-09-2005 09:35 AM
Well my first reactions was "now you tell me!"
Thanks CC!
With your mention of the word sieve you may have saved me from certain death in this competition. But I will not rule out my need of a "mathamortician" yet.
My version of the prime finding code was based on what I learned in grade school about prime numbers. I thought is an accomplishment when I figured out I did not have to check values larger the largest of consecutive primes divided into the number I was checking.
So in my intital attempt to figure out what a sieve was I found a posting in a web-page that said I did not have to check any value larger than the square-root of the number I was checking. At this point a light bulb went on when I realized my observation converged on the square-root. So I cleaned things up and it turns out I can now find all of the primes less than 100,000,000 in only 9 minutes and 47 seconds.
This code is uses only 4.6K and would probably be a competittor if there were not other more efficient techniques not previously known to a Math Wimp.
Back to the web and more searching. So after finding out that my approach is good for small numbers but just will not work for large numbers and reading about equivalence and matrix operations I was lamenting my situation to my wife over dinner. She THEN said "Sieve, I did one of those in college." So now I have a fresh approach that may help me.
Since I do not like throwing away my work and since the approach I am using can not be used in the "Challenge" I am attaching the code as an open example (in LV 7.1).
Feel free to sit back and laugh if you want. Just remeber that ther is a mean old bear chasing you armed with a sieve.
Message Edited by Ben on 10-09-2005 09:37 AM
Message Edited by Ben on 10-09-2005 09:38 AM
10-09-2005 03:43 PM
10-09-2005 04:29 PM
10-09-2005 06:59 PM
10-09-2005 10:37 PM
altenbach a écrit:
OK, CC. The gloves are off! Try to beat this! 😄 (everybody else, please ignore this post:o)
Ouch ! Not bad ! I'm really impressed ! I was sure you were improving your vi, but not to such an extent ! 😮
However, I also made some progress. 😉
Try this one and come back later ! :D:D:D
10-10-2005 12:37 AM - edited 10-10-2005 12:37 AM
Message Edited by altenbach on 10-09-2005 10:43 PM
10-10-2005 01:22 AM
10-10-2005 01:48 AM
10-10-2005 05:31 AM
10-10-2005 07:39 AM
@shoneill wrote:
He he I think I get it:
Bruce: Smaller "seed" arrays, such as the prime numbers up to 1000, are allowed.
Titou: An array up to 1000 prime numbers or an array with prime numbers, the greater one being less than 1000 ?
Bruce: You just can't have a table for all the prime numbers - you have to generate the majority of your prime numbers.
Altenbach: I guess you discovered my new algorithm!
Just out of curiosity. Where has the "primes up to 2,400,000" come from? Surely this isn't enough to allow a proper solution of the coding challenge, or am I missing something really major here...... I'm generating 5,7 million prime numbers each time.... 😞