Re: Vernon's Prime Sieve
From: Daniel McLaury (daniel_mcl_at_hotmail.com)
Date: 07/29/04
- Next message: William Elliot: "Re: uncountable product of discrete two-point spaces"
- Previous message: Duggy: "Re: Results 1 - 10 of about 222 for author:|-|erc torture"
- In reply to: vernonner3voltazim: "Re: Vernon's Prime Sieve"
- Next in thread: vernonner3voltazim: "Re: Vernon's Prime Sieve"
- Reply: vernonner3voltazim: "Re: Vernon's Prime Sieve"
- Messages sorted by: [ date ] [ thread ]
Date: 28 Jul 2004 22:42:44 -0700
Most compilers, including gcc, are smart enough to recognize walking an
array and create the extra variable for you, so I prefer to leave the
code as it stands for readability. And as to avoiding the modulus,
well, is there a better way to find the multiple of p which is closest
to N?
The Big-O is what matters; doubling the speed of something is really
not all that important compared to designing the program logic in a
manner which makes the calculations scale better on the input size.
After reviewing my code, I think that perhaps it might be better to
calculate the first 65536 primes and then loop through the numbers from
65537 to 2^32 and check each one with each prime, aborting when the
first one is found; in order to be sure, however, I'd have to do some
pencil and paper work; it's kinda hard for me to think while I type.
Finally, keep in mind that every time you print out an n-digit number
in decimal, you do n divisions, so adding a division somewhere in a
loop isn't really gonna hurt things all that much if there's printing
being done inside the loop.
I'll change the malloc values, and if that doesn't work, I'll try some
debugging.
- Next message: William Elliot: "Re: uncountable product of discrete two-point spaces"
- Previous message: Duggy: "Re: Results 1 - 10 of about 222 for author:|-|erc torture"
- In reply to: vernonner3voltazim: "Re: Vernon's Prime Sieve"
- Next in thread: vernonner3voltazim: "Re: Vernon's Prime Sieve"
- Reply: vernonner3voltazim: "Re: Vernon's Prime Sieve"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|