aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-04-09 23:12:38 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-04-09 23:12:38 +0200
commit7e5f2f3b5163a3c7c6b20a311f1177f9c4f04b81 (patch)
tree7f3b277b887c0a841120eac95db964f6ac63c5c6
parent1d232fd44026deae94c88200766152aec9d6c5e5 (diff)
downloadbusybox-w32-7e5f2f3b5163a3c7c6b20a311f1177f9c4f04b81.tar.gz
busybox-w32-7e5f2f3b5163a3c7c6b20a311f1177f9c4f04b81.tar.bz2
busybox-w32-7e5f2f3b5163a3c7c6b20a311f1177f9c4f04b81.zip
factor: expand comments
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/factor.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/coreutils/factor.c b/coreutils/factor.c
index e01190150..1c01e3f27 100644
--- a/coreutils/factor.c
+++ b/coreutils/factor.c
@@ -107,9 +107,12 @@ static NOINLINE void factorize(wide_t N)
107 factor = 3; 107 factor = 3;
108 factor2 = 3 * 3; 108 factor2 = 3 * 3;
109 for (;;) { 109 for (;;) {
110 while ((N % factor) == 0) { 110 /* The division is the most costly part of the loop.
111 * On 64bit CPUs, takes at best 12 cycles, often ~20.
112 */
113 while ((N % factor) == 0) { /* not likely */
111 N = N / factor; 114 N = N / factor;
112 printf(" %u"HALF_FMT"", factor); 115 printf(" %u"HALF_FMT, factor);
113 max_factor = isqrt_odd(N); 116 max_factor = isqrt_odd(N);
114 } 117 }
115 next_factor: 118 next_factor:
@@ -122,8 +125,8 @@ static NOINLINE void factorize(wide_t N)
122 factor += 2; 125 factor += 2;
123 /* Rudimentary wheel sieving: skip multiples of 3: 126 /* Rudimentary wheel sieving: skip multiples of 3:
124 * Every third odd number is divisible by three and thus isn't a prime: 127 * Every third odd number is divisible by three and thus isn't a prime:
125 * 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37... 128 * 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47...
126 * ^ ^ ^ ^ ^ ^ ^ _ ^ ^ _ ^ 129 * ^ ^ ^ ^ ^ ^ ^ _ ^ ^ _ ^ ^ ^ ^
127 * (^ = primes, _ = would-be-primes-if-not-divisible-by-5) 130 * (^ = primes, _ = would-be-primes-if-not-divisible-by-5)
128 */ 131 */
129 --count3; 132 --count3;