remove trailing spaces
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
diff --git a/etc/2kprime.c b/etc/2kprime.c
index 14da57e..f1cbcac 100644
--- a/etc/2kprime.c
+++ b/etc/2kprime.c
@@ -12,16 +12,16 @@ int main(void)
FILE *out;
clock_t t1;
mp_digit z;
-
+
mp_init_multi(&q, &p, NULL);
-
+
out = fopen("2kprime.1", "w");
for (x = 0; x < (int)(sizeof(sizes) / sizeof(sizes[0])); x++) {
top:
mp_2expt(&q, sizes[x]);
mp_add_d(&q, 3, &q);
z = -3;
-
+
t1 = clock();
for(;;) {
mp_sub_d(&q, 4, &q);
@@ -31,13 +31,13 @@ int main(void)
printf("No primes of size %d found\n", sizes[x]);
break;
}
-
- if (clock() - t1 > CLOCKS_PER_SEC) {
+
+ if (clock() - t1 > CLOCKS_PER_SEC) {
printf("."); fflush(stdout);
// sleep((clock() - t1 + CLOCKS_PER_SEC/2)/CLOCKS_PER_SEC);
t1 = clock();
}
-
+
/* quick test on q */
mp_prime_is_prime(&q, 1, &y);
if (y == 0) {
@@ -60,24 +60,19 @@ int main(void)
break;
}
-
+
if (y == 0) {
++sizes[x];
goto top;
}
-
+
mp_toradix(&q, buf, 10);
printf("\n\n%d-bits (k = %lu) = %s\n", sizes[x], z, buf);
fprintf(out, "%d-bits (k = %lu) = %s\n", sizes[x], z, buf); fflush(out);
}
-
+
return 0;
-}
-
-
-
-
-
+}
/* ref: $Format:%D$ */
/* git commit: $Format:%H$ */
diff --git a/etc/drprime.c b/etc/drprime.c
index 29d89db..c11c1c6 100644
--- a/etc/drprime.c
+++ b/etc/drprime.c
@@ -2,16 +2,17 @@
#include <tommath.h>
int sizes[] = { 1+256/DIGIT_BIT, 1+512/DIGIT_BIT, 1+768/DIGIT_BIT, 1+1024/DIGIT_BIT, 1+2048/DIGIT_BIT, 1+4096/DIGIT_BIT };
+
int main(void)
{
int res, x, y;
char buf[4096];
FILE *out;
mp_int a, b;
-
+
mp_init(&a);
mp_init(&b);
-
+
out = fopen("drprimes.txt", "w");
for (x = 0; x < (int)(sizeof(sizes)/sizeof(sizes[0])); x++) {
top:
@@ -21,14 +22,14 @@ int main(void)
for (y = 1; y < sizes[x]; y++) {
a.dp[y] = MP_MASK;
}
-
+
/* make a DR modulus */
a.dp[0] = -1;
a.used = sizes[x];
-
+
/* now loop */
res = 0;
- for (;;) {
+ for (;;) {
a.dp[0] += 4;
if (a.dp[0] >= MP_MASK) break;
mp_prime_is_prime(&a, 1, &res);
@@ -36,29 +37,28 @@ int main(void)
printf("."); fflush(stdout);
mp_sub_d(&a, 1, &b);
mp_div_2(&b, &b);
- mp_prime_is_prime(&b, 3, &res);
+ mp_prime_is_prime(&b, 3, &res);
if (res == 0) continue;
mp_prime_is_prime(&a, 3, &res);
if (res == 1) break;
}
-
+
if (res != 1) {
printf("Error not DR modulus\n"); sizes[x] += 1; goto top;
} else {
mp_toradix(&a, buf, 10);
printf("\n\np == %s\n\n", buf);
fprintf(out, "%d-bit prime:\np == %s\n\n", mp_count_bits(&a), buf); fflush(out);
- }
+ }
}
fclose(out);
-
+
mp_clear(&a);
mp_clear(&b);
-
+
return 0;
}
-
/* ref: $Format:%D$ */
/* git commit: $Format:%H$ */
/* commit time: $Format:%ai$ */
diff --git a/etc/mersenne.c b/etc/mersenne.c
index 432cec1..ca6ee5f 100644
--- a/etc/mersenne.c
+++ b/etc/mersenne.c
@@ -1,4 +1,4 @@
-/* Finds Mersenne primes using the Lucas-Lehmer test
+/* Finds Mersenne primes using the Lucas-Lehmer test
*
* Tom St Denis, tomstdenis@gmail.com
*/
@@ -10,7 +10,7 @@ is_mersenne (long s, int *pp)
{
mp_int n, u;
int res, k;
-
+
*pp = 0;
if ((res = mp_init (&n)) != MP_OKAY) {
diff --git a/etc/mont.c b/etc/mont.c
index ac14e06..e41ad45 100644
--- a/etc/mont.c
+++ b/etc/mont.c
@@ -13,21 +13,21 @@ int main(void)
/* loop through various sizes */
for (x = 4; x < 256; x++) {
printf("DIGITS == %3ld...", x); fflush(stdout);
-
+
/* make up the odd modulus */
mp_rand(&modulus, x);
modulus.dp[0] |= 1;
-
+
/* now find the R value */
mp_montgomery_calc_normalization(&R, &modulus);
mp_montgomery_setup(&modulus, &mp);
-
+
/* now run through a bunch tests */
for (y = 0; y < 1000; y++) {
mp_rand(&p, x/2); /* p = random */
mp_mul(&p, &R, &pp); /* pp = R * p */
mp_montgomery_reduce(&pp, &modulus, mp);
-
+
/* should be equal to p */
if (mp_cmp(&pp, &p) != MP_EQ) {
printf("FAILURE!\n");
@@ -36,15 +36,10 @@ int main(void)
}
printf("PASSED\n");
}
-
+
return 0;
}
-
-
-
-
-
/* ref: $Format:%D$ */
/* git commit: $Format:%H$ */
/* commit time: $Format:%ai$ */