mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Verify that h*2^n-1 is not a multiple of 3
This commit is contained in:
@@ -1041,7 +1041,8 @@ next_x = 129;
|
||||
* n n as in h*2^n-1 (must be >= 1)
|
||||
*
|
||||
* output:
|
||||
* returns v(1), or -1 is there is no quick way
|
||||
* returns v(1), or
|
||||
* -1 when h*2^n-1 is a multiple of 3
|
||||
*/
|
||||
define
|
||||
gen_v1(h, n)
|
||||
@@ -1068,6 +1069,14 @@ gen_v1(h, n)
|
||||
quit "bad args: n must be an integer >= 1";
|
||||
}
|
||||
|
||||
/*
|
||||
* pretest: Verify that h*2^n-1 is not a multiple of 3
|
||||
*/
|
||||
if (((h % 3 == 1) && (n % 2 == 0)) || ((h % 3 == 2) && (n % 2 == 1))) {
|
||||
/* no need to test h*2^n-1, it is not prime */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* check for Case 1: (h mod 3 != 0)
|
||||
*/
|
||||
|
Reference in New Issue
Block a user