1. tt
Member
Join Date
Dec 1969
Posts
46

Hi there! <BR>Trying again...<BR><BR>Has anyone out there implemented the new Prime algorithm in VB or VB script by Manindra Agrawal that is known to be extremly fast and actually correct.<BR>What he and hes coworkers has done is an breaktrough in mathemathics but I have problem writing it in VB...<BR><BR>What i need is to feed hes function with "longs" and retrive False or True depending on the result.<BR><BR>Hes work and algorithm can be found here: <BR>http://www.cse.iitk.ac.in/news/primality.pdf <BR><BR>Thanks in advance // TT

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## ****! I wrote a long reply...

...and this stupid system wipe it out!<BR><BR>The guts of it were that this is *NOT* an algorithm to be used with "ordinary" numbers. It&#039;s for finding primes in numbers that have dozens and hundreds of digits. Some the minor algorithms that you need just to implement the outer algorithm are non-trivial in the amount of time they would take, just to begin with!<BR><BR>Oh, what the heck, I&#039;ll rewrite one of them:<BR><BR>1. if ( n is of the form a^b where b &#062; 1 ) output COMPOSITE;<BR><BR>&#060;%<BR>Function isPower( n )<BR> power = 2<BR> Do<BR> root = n ^ (1.0/power)<BR> If root &#060; 2 Then <BR> isPower = False<BR> Exit Function<BR> End If<BR> &#039; test to see if this is a perfect root...<BR> &#039; because of inherit errors in calculation of roots, we have to do this:<BR> root = Round(root)<BR> If n = root ^ pwr Then<BR> isPower = True<BR> Exit Function<BR> End If<BR> Loop &#039; we depend on test, above, to get us out of loop<BR>End Function<BR>%&#062;<BR><BR>BUT...<BR><BR>But this is ONLY going to work with numbers of no more than 14 or 15 digits! Beyond that, the inherit mechanism of floating point numbers will make it not work. I wouldn&#039;t *really* count on it working for more than 9 digits, if truth be known.<BR><BR>***********<BR><BR>So...<BR><BR>That algorithm is *NOT* for ordinary prime testing. It&#039;s for testing *REALLY* large numbers. And it requires a completely custom arithmetic library that is capable of doing math that is accurate to dozens and hundreds of digits. Which no standard software can do.<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•