aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/division/sum_div.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/monniaux/division/sum_div.c')
-rw-r--r--test/monniaux/division/sum_div.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/monniaux/division/sum_div.c b/test/monniaux/division/sum_div.c
new file mode 100644
index 00000000..87256922
--- /dev/null
+++ b/test/monniaux/division/sum_div.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "../clock.h"
+
+int main(int argc, char **argv) {
+ unsigned modulus = argc < 2 ? 3371 : atoi(argv[1]);
+ clock_prepare();
+ clock_start();
+ unsigned total=0, total_mod=0;
+ for(int i=0; i<1000; i++) {
+ total += i;
+ total_mod = (total_mod + i)%modulus;
+ }
+ clock_stop();
+ print_total_clock();
+ printf("%u %u %d\n", total, total_mod, total%modulus == total_mod);
+ return 0;
+}