1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 2006-2019 Free Software Foundation, Inc.
3 *
4 * This file is not part of the GNU gettext program, but is used with
5 * GNU gettext.
6 *
7 * The original copyright notice is as follows:
8 */
9
10 /* GLIB - Library of useful routines for C programming
11 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
12 *
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the
25 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 * Boston, MA 02111-1307, USA.
27 */
28
29 /*
30 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
31 * file for a list of people on the GLib Team. See the ChangeLog
32 * files for a list of changes. These files are distributed with
33 * GLib at ftp://ftp.gtk.org/pub/gtk/.
34 */
35
36 /*
37 * Modified by Bruno Haible for use as a gnulib module.
38 */
39
40 /*
41 * MT safe
42 */
43
44 #include "config.h"
45
46 #include "glib.h"
47 #if 0
48 #include "galias.h"
49 #endif
50
51
52 static const guint g_primes[] =
53 {
54 11,
55 19,
56 37,
57 73,
58 109,
59 163,
60 251,
61 367,
62 557,
63 823,
64 1237,
65 1861,
66 2777,
67 4177,
68 6247,
69 9371,
70 14057,
71 21089,
72 31627,
73 47431,
74 71143,
75 106721,
76 160073,
77 240101,
78 360163,
79 540217,
80 810343,
81 1215497,
82 1823231,
83 2734867,
84 4102283,
85 6153409,
86 9230113,
87 13845163,
88 };
89
90 static const guint g_nprimes = sizeof (g_primes) / sizeof (g_primes[0]);
91
92 guint
g_spaced_primes_closest(guint num)93 g_spaced_primes_closest (guint num)
94 {
95 gint i;
96
97 for (i = 0; i < g_nprimes; i++)
98 if (g_primes[i] > num)
99 return g_primes[i];
100
101 return g_primes[g_nprimes - 1];
102 }
103
104 #if 0
105 #define __G_PRIMES_C__
106 #include "galiasdef.c"
107 #endif
108