/* * pix - number of primes less than a small value * * Copyright (C) 1999 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License * as published by the Free Software Foundation. * * Calc 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 Lesser General * Public License for more details. * * A copy of version 2.1 of the GNU Lesser General Public License is * distributed with calc under the filename COPYING-LGPL. You should have * received a copy with calc; if not, write to Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * @(#) $Revision: 30.1 $ * @(#) $Id: pix.c,v 30.1 2007/03/16 11:09:46 chongo Exp $ * @(#) $Source: /usr/local/src/bin/calc/RCS/pix.c,v $ * * Under source code control: 1994/07/01 19:44:21 * File existed as early as: 1994 * * chongo /\oo/\ http://www.isthe.com/chongo/ * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ */ #include "zmath.h" #include "prime.h" #include "have_const.h" /* * pi10b - number of primes <= 2^18 in multiples of 2^10 * * pi10b[x] == pi(x*1024) for 0 <= x <= 256 */ CONST unsigned short pi10b[(MAX_PI10B/1024)+1+1] = { 0, 172, 309, 439, 564, 685, 801, 916, 1028, 1142, 1254, 1362, 1469, 1580, 1681, 1794, 1900, 2002, 2110, 2205, 2312, 2413, 2517, 2618, 2725, 2818, 2918, 3016, 3124, 3221, 3314, 3414, 3512, 3619, 3716, 3808, 3908, 4006, 4098, 4197, 4288, 4391, 4495, 4583, 4678, 4767, 4858, 4956, 5051, 5152, 5239, 5339, 5432, 5520, 5616, 5711, 5814, 5908, 6003, 6094, 6179, 6270, 6363, 6453, 6542, 6636, 6734, 6820, 6906, 6999, 7095, 7190, 7281, 7371, 7465, 7550, 7649, 7733, 7824, 7915, 8009, 8103, 8187, 8277, 8363, 8453, 8548, 8630, 8727, 8812, 8899, 9000, 9087, 9180, 9271, 9357, 9439, 9533, 9618, 9708, 9805, 9886, 9971, 10062, 10151, 10236, 10324, 10416, 10499, 10585, 10674, 10761, 10846, 10930, 11021, 11110, 11196, 11282, 11371, 11462, 11554, 11641, 11729, 11816, 11900, 11987, 12079, 12163, 12251, 12333, 12425, 12507, 12589, 12680, 12777, 12861, 12941, 13032, 13125, 13212, 13289, 13372, 13452, 13546, 13631, 13712, 13807, 13894, 13982, 14072, 14159, 14242, 14327, 14407, 14497, 14577, 14662, 14750, 14835, 14915, 14999, 15086, 15167, 15247, 15334, 15408, 15495, 15585, 15670, 15758, 15843, 15925, 16003, 16097, 16173, 16264, 16357, 16433, 16519, 16601, 16690, 16775, 16869, 16954, 17032, 17119, 17200, 17282, 17369, 17457, 17536, 17623, 17704, 17789, 17877, 17957, 18038, 18118, 18205, 18285, 18367, 18450, 18535, 18624, 18710, 18798, 18889, 18974, 19045, 19130, 19213, 19290, 19370, 19453, 19541, 19628, 19709, 19797, 19876, 19960, 20043, 20126, 20206, 20288, 20379, 20476, 20552, 20632, 20709, 20787, 20870, 20946, 21022, 21109, 21191, 21272, 21359, 21446, 21527, 21613, 21695, 21776, 21859, 21950, 22031, 22106, 22196, 22276, 22358, 22435, 22525, 22599, 22678, 22765, 22845, 22925, 23000 }; /* * pi18b - primes found in a given 2^18 interval * * i