PrimeGeneration.PAS
Upload User: master
Upload Date: 2007-01-06
Package Size: 17k
Code Size: 2k
Development Platform:

Pascal

  1. {License, info, etc
  2.  ------------------
  3. This implementation is made by Walied Othman, to contact me 
  4. mail to Walied.Othman@Student.KULeuven.ac.be or 
  5. Triade@ace.Ulyssis.Student.KULeuven.ac.be, or ICQ me on 20388046.  
  6. If you 're going to use these implementations, at least mention my 
  7. name or something and notify me so I may even put a link on my page.  
  8. This implementation is freeware and according to the coderpunks' 
  9. manifesto it should remain so, so don 't use these implementations 
  10. in commercial applications.  Encryption, as a tool to ensure privacy 
  11. should be free and accessible for anyone.  If you plan to use these 
  12. implementations in a commercial application, contact me before 
  13. doing so.  If any algorithm is patented in your country, you should 
  14. acquire a license before using this software.  Modified versions of this 
  15. software must remain in the public domain and must contain an 
  16. acknowledgement of the original author (=me).  
  17. This implementaion is available at 
  18. http://ace.ulyssis.student.kuleuven.ac.be/~triade/GInt/index.htm
  19. copyright 1999, Walied Othman
  20. This header may not be removed.}
  21. Unit PrimeGeneration;
  22. Interface
  23. Uses Windows, SysUtils, Controls, GInt;
  24. Procedure PrimeSearch(Var GInt : TGInt);
  25. Implementation
  26. {$H+}
  27. // Does an incremental search for primes starting from GInt,
  28. // when one is found, it is stored in GInt
  29. Procedure PrimeSearch(Var GInt : TGInt);
  30. Var
  31.    temp, two : TGInt;
  32.    ok : Boolean;
  33. Begin
  34.    If (GInt^.value Mod 2) = 0 Then GInt^.value := GInt^.value + 1;
  35.    DecStrToGInt('2', two);
  36.    ok := false;
  37.    While Not ok Do
  38.    Begin
  39.       GIntAdd(GInt, two, temp);
  40.       GIntdestroy(GInt);
  41.       GInt := temp;
  42.       GIntPrimeTest(GInt, 5, ok);
  43.    End;
  44.    GIntDestroy(two);
  45. End;
  46. End.