-
Notifications
You must be signed in to change notification settings - Fork 0
/
x_neg_k.cpp
60 lines (43 loc) · 1.15 KB
/
x_neg_k.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// a(n) is the least integer k > 2 such that the remainder of -k modulo p is strictly increasing over the first n primes.
// https://oeis.org/A306612
// a(16) = 118867612
// a(17) = 4968215191
// a(18) = 31090893772
// a(19) = 118903377091
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
long long int p = 71;
long long int primes[19] = {67, 61, 59, 53, 47, 43, 41, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2};
for ( long long int k = 118903377091LL; ; ++k) {
//cout << k << endl;
auto max = (-k) % p;
//cout << max << " -- " << max + p << endl;
if (max < 0) {
max += p;
}
bool ok = true;
//cout << max << endl;
for (auto q : primes) {
auto t = (-k) % q;
if (t < 0) {
t += q;
}
if (t < max) {
max = t;
}
else {
ok = false;
break;
}
}
if (ok) {
cout << "Found\n";
cout << k << "\n";
break;
}
}
}