[SCM] Lisaac compiler branch, master, updated. lisaac-0.12-436-g6cd5626

ontologiae ontologiae at cam44-3-82-235-75-162.fbx.proxad.net
Sun Aug 23 00:27:12 UTC 2009


The following commit has been merged in the master branch:
commit 6cd562695204f4e03750e3e257b0aa8d3cd4801d
Author: ontologiae <ontologiae at cam44-3-82-235-75-162.fbx.proxad.net>
Date:   Sun Aug 23 02:26:39 2009 +0200

    is_prime ok

diff --git a/lib/number/integer.li b/lib/number/integer.li
index 970ced2..c52e997 100644
--- a/lib/number/integer.li
+++ b/lib/number/integer.li
@@ -305,22 +305,31 @@ Section Public
     +? {result == other.gcd self};
   ];
 
+
   - is_prime : BOOLEAN <-
   // TRUE if `Self' is prime
   ( + diviseur : INTEGER;
     + sqrt_s : INTEGER;
     + result : BOOLEAN;
-
-    sqrt_s := sqrt;
-    ((Self % 2 != 0) || {Self % 3 != 0}).if {
-      1.to ((sqrt_s+1)/6) until {(Self % diviseur) = 0} do { cpt : INTEGER;
-        diviseur := 6 * cpt - ((cpt & 1) << 1) + 1;
-      };
-      result := diviseur.in_range (sqrt_s - 6) to (sqrt_s + 6);
-    };
-    result
+    //"debut test primalité".println; 
+    diviseur := 5;
+    sqrt_s := Self.sqrt;
+    result := FALSE;
+    ((Self % 2 = 0) || {Self % 3 = 0}).if_false {
+     result := TRUE;
+     //sqrt_s.println;"--".println;
+     1.to sqrt_s until {(Self % diviseur) = 0} do { cpt : INTEGER;
+       //"Boucle:  cpt,diviseur = ".print;((cpt-1) & 1).println;
+       diviseur := diviseur + 2 + (((cpt-1) & 1) << 1);
+       //diviseur.println;
+     };
+     result := result  && {!((Self % diviseur) = 0)};
+  };
+  result
   );
 
+
+
   //
   // Random
   //

-- 
Lisaac compiler



More information about the Lisaac-commits mailing list