mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
convert ASCII TABs to ASCII SPACEs
Converted all ASCII tabs to ASCII spaces using a 8 character tab stop, for all files, except for all Makefiles (plus rpm.mk). The `git diff -w` reports no changes.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
*
|
||||
* 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
|
||||
* 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
|
||||
@@ -17,11 +17,11 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Under source code control: 1994/03/14 23:11:21
|
||||
* File existed as early as: 1994
|
||||
* Under source code control: 1994/03/14 23:11:21
|
||||
* File existed as early as: 1994
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
@@ -32,37 +32,37 @@ read -once "lucas.cal"
|
||||
* randmprime - find a random prime of the form h*2^n-1 of a given size
|
||||
*
|
||||
* given:
|
||||
* bits minimum bits in prime to return
|
||||
* seed random seed for srandom()
|
||||
* [dbg] if given, enable debugging
|
||||
* bits minimum bits in prime to return
|
||||
* seed random seed for srandom()
|
||||
* [dbg] if given, enable debugging
|
||||
*
|
||||
* returns:
|
||||
* a prime of the form h*2^n-1
|
||||
* a prime of the form h*2^n-1
|
||||
*/
|
||||
define
|
||||
randmprime(bits, seed, dbg)
|
||||
{
|
||||
local n; /* n as in h*2^n-1 */
|
||||
local h; /* h as in h*2^n-1 */
|
||||
local plush; /* value added to h since the beginning */
|
||||
local init; /* initial CPU time */
|
||||
local start; /* CPU time before last test */
|
||||
local stop; /* CPU time after last test */
|
||||
local tmp; /* just a tmp place holder value */
|
||||
local ret; /* h*2^n-1 that is prime */
|
||||
local n; /* n as in h*2^n-1 */
|
||||
local h; /* h as in h*2^n-1 */
|
||||
local plush; /* value added to h since the beginning */
|
||||
local init; /* initial CPU time */
|
||||
local start; /* CPU time before last test */
|
||||
local stop; /* CPU time after last test */
|
||||
local tmp; /* just a tmp place holder value */
|
||||
local ret; /* h*2^n-1 that is prime */
|
||||
|
||||
/* firewall */
|
||||
if (param(0) < 2 || param(0) > 3) {
|
||||
quit "bad usage: rndprime(dig, seed [,dbg])";
|
||||
quit "bad usage: rndprime(dig, seed [,dbg])";
|
||||
}
|
||||
if (!isint(bits) || bits < 0 || !isint(seed) || seed < 0) {
|
||||
quit "args must be non-negative integers";
|
||||
quit "args must be non-negative integers";
|
||||
}
|
||||
if (bits < 1) {
|
||||
bits = 1;
|
||||
bits = 1;
|
||||
}
|
||||
if (param(0) == 2 || dbg < 0) {
|
||||
dbg = 0;
|
||||
dbg = 0;
|
||||
}
|
||||
|
||||
/* seed generator */
|
||||
@@ -76,57 +76,57 @@ randmprime(bits, seed, dbg)
|
||||
++n;
|
||||
}
|
||||
if (dbg >= 1) {
|
||||
print "DEBUG3: initial h =", h;
|
||||
print "DEBUG3: initial n =", n;
|
||||
print "DEBUG3: initial h =", h;
|
||||
print "DEBUG3: initial n =", n;
|
||||
}
|
||||
|
||||
/*
|
||||
* loop until we find a prime
|
||||
*/
|
||||
if (dbg >= 1) {
|
||||
start = usertime();
|
||||
init = usertime();
|
||||
plush = 0;
|
||||
print "DEBUG1: testing (h+" : plush : ")*2^" : n : "-1";
|
||||
start = usertime();
|
||||
init = usertime();
|
||||
plush = 0;
|
||||
print "DEBUG1: testing (h+" : plush : ")*2^" : n : "-1";
|
||||
}
|
||||
while (lucas(h,n) == 0) {
|
||||
|
||||
/* bump h, and n if needed */
|
||||
if (dbg >= 2) {
|
||||
stop = usertime();
|
||||
print "DEBUG2: last test:", stop-start, " total time:", stop-init;
|
||||
}
|
||||
if (dbg >= 1) {
|
||||
print "DEBUG1: composite: (h+" : plush : ")*2^" : n : "-1";
|
||||
plush += 2;
|
||||
}
|
||||
h += 2;
|
||||
while (highbit(h) >= n) {
|
||||
++n;
|
||||
}
|
||||
if (dbg >= 1) {
|
||||
print "DEBUG1: testing (h+" : plush : ")*2^" : n : "-1";
|
||||
start = stop;
|
||||
}
|
||||
/* bump h, and n if needed */
|
||||
if (dbg >= 2) {
|
||||
stop = usertime();
|
||||
print "DEBUG2: last test:", stop-start, " total time:", stop-init;
|
||||
}
|
||||
if (dbg >= 1) {
|
||||
print "DEBUG1: composite: (h+" : plush : ")*2^" : n : "-1";
|
||||
plush += 2;
|
||||
}
|
||||
h += 2;
|
||||
while (highbit(h) >= n) {
|
||||
++n;
|
||||
}
|
||||
if (dbg >= 1) {
|
||||
print "DEBUG1: testing (h+" : plush : ")*2^" : n : "-1";
|
||||
start = stop;
|
||||
}
|
||||
}
|
||||
|
||||
/* found a prime */
|
||||
if (dbg >= 2) {
|
||||
stop = usertime();
|
||||
print "DEBUG2: last test:", stop-start, " total time:", stop-init;
|
||||
print "DEBUG3: " : h : "*2^" : n : "-1 is prime";
|
||||
stop = usertime();
|
||||
print "DEBUG2: last test:", stop-start, " total time:", stop-init;
|
||||
print "DEBUG3: " : h : "*2^" : n : "-1 is prime";
|
||||
}
|
||||
if (dbg >= 1) {
|
||||
print "DEBUG1: prime: (h+" : plush : ")*2^" : n : "-1";
|
||||
print "DEBUG1: prime: (h+" : plush : ")*2^" : n : "-1";
|
||||
}
|
||||
ret = h*2^n-1;
|
||||
if (dbg >= 3) {
|
||||
print "DEBUG3: highbit(h):", highbit(h);
|
||||
print "DEBUG3: digits(h):", digits(h);
|
||||
print "DEBUG3: highbit(n):", highbit(n);
|
||||
print "DEBUG3: digits(2^n):", int(n*ln(10)/ln(2)+1);
|
||||
print "DEBUG3: highbit(h*2^n-1):", highbit(ret);
|
||||
print "DEBUG3: digits(h*2^n)-1:", digits(ret);
|
||||
print "DEBUG3: highbit(h):", highbit(h);
|
||||
print "DEBUG3: digits(h):", digits(h);
|
||||
print "DEBUG3: highbit(n):", highbit(n);
|
||||
print "DEBUG3: digits(2^n):", int(n*ln(10)/ln(2)+1);
|
||||
print "DEBUG3: highbit(h*2^n-1):", highbit(ret);
|
||||
print "DEBUG3: digits(h*2^n)-1:", digits(ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user