Lines Matching +full:1 +full:- +full:stop
11 * 1. Redistributions of source code must retain the above copyright
34 * primes - generate a table of primes between two values
38 * chongo <for a good prime call: 391581 * 2^216193 - 1> /\oo/\
41 * primes [-h] [start [stop]]
43 * Print primes >= start and < stop. If stop is omitted,
44 * the value 18446744073709551615 (2^64-1) is assumed. If
69 * odd. If the base of table is 1, table[i] represents 2*i-1. After the
70 * sieve, table[i] == 1 if and only if 2*i-1 is prime.
86 ubig stop; /* don't generate at or above this value */ in main() local
92 err(1, "cap_enter"); in main()
94 while ((ch = getopt(argc, argv, "h")) != -1) in main()
103 argc -= optind; in main()
107 stop = (uint64_t)(-1); in main()
117 /* Start and stop supplied on the command line. */ in main()
118 if (argv[0][0] == '-' || argv[1][0] == '-') in main()
119 errx(1, "negative numbers aren't permitted."); in main()
124 err(1, "%s", argv[0]); in main()
126 errx(1, "%s: illegal numeric format.", argv[0]); in main()
129 stop = strtoumax(argv[1], &p, 0); in main()
131 err(1, "%s", argv[1]); in main()
133 errx(1, "%s: illegal numeric format.", argv[1]); in main()
135 case 1: in main()
137 if (argv[0][0] == '-') in main()
138 errx(1, "negative numbers aren't permitted."); in main()
143 err(1, "%s", argv[0]); in main()
145 errx(1, "%s: illegal numeric format.", argv[0]); in main()
154 if (start > stop) in main()
155 errx(1, "start value must be less than stop value."); in main()
156 primes(start, stop); in main()
161 * read_num_buf --
173 err(1, "stdin"); in read_num_buf()
179 if (*p == '-') in read_num_buf()
180 errx(1, "negative numbers aren't permitted."); in read_num_buf()
184 err(1, "%s", buf); in read_num_buf()
186 errx(1, "%s: illegal numeric format.", buf); in read_num_buf()
192 * primes - sieve and print primes from start up to and but not including stop
195 primes(ubig start, ubig stop) in primes() argument
212 if (stop < 3) { in primes()
213 stop = (ubig)2; in primes()
215 if (stop <= start) { in primes()
225 if (stop != 2 && (stop&0x1) == 0) { in primes()
226 ++stop; in primes()
235 factor < stop && p <= pr_limit; factor = *(++p)) { in primes()
249 * upward until we pass the stop point in primes()
251 while (start < stop) { in primes()
257 memcpy(table, &pattern[factor], pattern_size-factor); in primes()
259 for (fact_lim=pattern_size-factor; in primes()
264 memcpy(&table[fact_lim], pattern, TABSIZE-fact_lim); in primes()
270 if (stop-start > TABSIZE+TABSIZE) { in primes()
274 tab_lim = &table[(stop-start)/2]; /* partial sieve */ in primes()
275 fact_lim = sqrt(stop+1.0); in primes()
284 q = &table[(factor-mod)/2]; in primes()
286 q = &table[mod ? factor-(mod/2) : 0]; in primes()
313 fprintf(stderr, "usage: primes [-h] [start [stop]]\n"); in usage()
314 exit(1); in usage()