From da36e62c7f764a555142a4dfa23237fce43478c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Romain=20Lef=C3=A8bvre?= <r.lefebvre@student.uclouvain.be>
Date: Mon, 13 Apr 2020 21:07:04 +0200
Subject: [PATCH] fonction de prime facto la plus rapide des 3.

---
 main.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)
 create mode 100644 main.c

diff --git a/main.c b/main.c
new file mode 100644
index 0000000..7f87cf6
--- /dev/null
+++ b/main.c
@@ -0,0 +1,75 @@
+# include <stdio.h>
+#include <math.h>
+#include <sys/time.h>
+
+// A function to print all prime factors of a given number n
+
+# include <stdio.h>
+# include <math.h>
+
+// A function to print all prime factors of a given number n
+void primeFactors(int n)
+{
+    int count1=0;
+    int count2=0;
+    while (n%2 == 0)
+    {
+        if(count1==0) printf("%d ", 2);
+        n = n/2;
+        count1+=1;
+    }
+    for (int i = 3; i <= sqrt(n); i = i+2)
+    {
+        while (n%i == 0)
+        {
+            if(count2==0) printf("%d ", i);
+            n=n/i;
+            count2+=1;
+        }
+        count2=0;
+    }
+    if (n > 2)
+        printf ("%d ", n);
+}
+
+/* Driver program to test above function */
+
+int main() {
+    struct timeval stop, start;
+    gettimeofday(&start, NULL);
+    int n = 666343;
+    primeFactors(n);
+    printf("\n");
+    int b = 463698;
+    primeFactors(b);
+    printf("\n");
+    int c = 1021406;
+    primeFactors(c);
+    printf("\n");
+    int d = 506156;
+    primeFactors(d);
+    printf("\n");
+    int e = 913231;
+    primeFactors(e);
+    printf("\n");
+    int f = 268205;
+    primeFactors(f);
+    printf("\n");
+    int g = 982865;
+    primeFactors(g);
+    printf("\n");
+    int h = 917451;
+    primeFactors(h);
+    printf("\n");
+    gettimeofday(&stop, NULL);
+    printf("%lu", (stop.tv_sec - start.tv_sec) * 1000000 + stop.tv_usec - start.tv_usec);
+    return 0;
+}
+
+
+
+
+
+
+
+
-- 
GitLab