|
-
Dec 22nd, 2011, 05:01 PM
#22
Frenzied Member
Re: Prime number code
Kaliman makes and observation that i had missed
he is correctly states that the test does not need to go right upto the value being tested
but instead only half way
so function isprime can work much faster ( potentially twice as fast ) if we change the limits of the test loop
and the divisible by 2 doenot need to be tested as the candidates are all odd
so
For F = 2 To arg-1 ' arg is the value you want to test we know it devides itself
' can anything smaller devide it
'becomes
For F = 3 To arg/2 ' arg is the value you want to test we know it devides itself
' can anything half its size or less devide it
this is looking better all the time
here to talk
Last edited by incidentals; Dec 22nd, 2011 at 05:07 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|