summaryrefslogtreecommitdiffstats
path: root/lib/next_prime.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/next_prime.c')
-rw-r--r--lib/next_prime.c54
1 files changed, 0 insertions, 54 deletions
diff --git a/lib/next_prime.c b/lib/next_prime.c
deleted file mode 100644
index 5d608046..00000000
--- a/lib/next_prime.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Determine prime number.
- Copyright (C) 2000, 2002 Free Software Foundation, Inc.
- Written by Ulrich Drepper <drepper@redhat.com>, 2000.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, version 2.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stddef.h>
-
-
-/* Test whether CANDIDATE is a prime. */
-static int
-is_prime (size_t candidate)
-{
- /* No even number and none less than 10 will be passed here. */
- size_t divn = 3;
- size_t sq = divn * divn;
-
- while (sq < candidate && candidate % divn != 0)
- {
- size_t old_sq = sq;
- ++divn;
- sq += 4 * divn;
- if (sq < old_sq)
- return 1;
- ++divn;
- }
-
- return candidate % divn != 0;
-}
-
-
-/* We need primes for the table size. */
-size_t
-next_prime (size_t seed)
-{
- /* Make it definitely odd. */
- seed |= 1;
-
- while (!is_prime (seed))
- seed += 2;
-
- return seed;
-}