mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.10.3t5.45
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* randmprime - generate a random prime of the form h*2^n-1
|
||||
*
|
||||
* Copyright (c) 1995 by Landon Curt Noll. All Rights Reserved.
|
||||
* Copyright (c) 1997 by Landon Curt Noll. All Rights Reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
@@ -25,7 +25,6 @@
|
||||
*/
|
||||
|
||||
/* obtain our required libs */
|
||||
read -once "cryrand.cal"
|
||||
read -once "lucas.cal"
|
||||
|
||||
/*
|
||||
@@ -33,7 +32,7 @@ read -once "lucas.cal"
|
||||
*
|
||||
* given:
|
||||
* bits minimum bits in prime to return
|
||||
* seed random seed for scryrand()
|
||||
* seed random seed for srandom()
|
||||
* [dbg] if given, enable debugging
|
||||
*
|
||||
* returns:
|
||||
@@ -66,11 +65,11 @@ randmprime(bits, seed, dbg)
|
||||
}
|
||||
|
||||
/* seed generator */
|
||||
tmp = scryrand(seed);
|
||||
tmp = srandom(seed, 13);
|
||||
|
||||
/* determine initial h and n values */
|
||||
n = random(bits>>1, highbit(bits)+bits>>1+1);
|
||||
h = cryrand(n);
|
||||
h = randombit(n);
|
||||
h += iseven(h);
|
||||
while (highbit(h) >= n) {
|
||||
++n;
|
||||
@@ -131,7 +130,6 @@ randmprime(bits, seed, dbg)
|
||||
return ret;
|
||||
}
|
||||
|
||||
global lib_debug;
|
||||
if (lib_debug >= 0) {
|
||||
if (config("lib_debug") >= 0) {
|
||||
print "randmprime(bits, seed [,dbg]) defined";
|
||||
}
|
||||
|
Reference in New Issue
Block a user