Carmichael revision
This commit is contained in:
parent
4b174af020
commit
13ee965026
1 changed files with 3 additions and 1 deletions
|
@ -38,6 +38,7 @@ static void print_factors(vector<size_t> factors) {
|
||||||
|
|
||||||
|
|
||||||
static bool is_prime(size_t n) {
|
static bool is_prime(size_t n) {
|
||||||
|
|
||||||
bool is_prime = true;
|
bool is_prime = true;
|
||||||
for (size_t j = 3; j * j <= n; j += 2) {
|
for (size_t j = 3; j * j <= n; j += 2) {
|
||||||
if (n % j == 0) {
|
if (n % j == 0) {
|
||||||
|
@ -45,6 +46,7 @@ static bool is_prime(size_t n) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return is_prime;
|
return is_prime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +70,7 @@ static bool is_carmichael(size_t n) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print_factors(factors);
|
print_factors(factors);
|
||||||
cout << " = " << n << endl;;
|
cout << " = " << n << " with " << factors.size() << " prime factors." << endl;;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue