EKG sequence convergence: Difference between revisions

Content added Content deleted
(→‎{{header|Kotlin}}: Extended to generate EKG(9) and EKG(10) and the first 30 terms for all 5 cases.)
(→‎{{header|C}}: Extended to generate EKG(9) and EKG(10) and the first 30 terms for all 5 cases.)
Line 75: Line 75:
int main() {
int main() {
int s, n, i;
int s, n, i;
int starts[3] = {2, 5, 7};
int starts[5] = {2, 5, 7, 9, 10};
int ekg[3][LIMIT];
int ekg[5][LIMIT];
for (s = 0; s < 3; ++s) {
for (s = 0; s < 5; ++s) {
ekg[s][0] = 1;
ekg[s][0] = 1;
ekg[s][1] = starts[s];
ekg[s][1] = starts[s];
Line 90: Line 90:
}
}
}
}
printf("EKG(%d): [", starts[s]);
printf("EKG(%2d): [", starts[s]);
for (i = 0; i < 10; ++i) printf("%d ", ekg[s][i]);
for (i = 0; i < 30; ++i) printf("%d ", ekg[s][i]);
printf("\b]\n");
printf("\b]\n");
}
}

// now compare EKG5 and EKG7 for convergence
// now compare EKG5 and EKG7 for convergence
for (i = 2; i < LIMIT; ++i) {
for (i = 2; i < LIMIT; ++i) {
Line 108: Line 108:
{{out}}
{{out}}
<pre>
<pre>
EKG(2): [1 2 4 6 3 9 12 8 10 5]
EKG( 2): [1 2 4 6 3 9 12 8 10 5 15 18 14 7 21 24 16 20 22 11 33 27 30 25 35 28 26 13 39 36]
EKG(5): [1 5 10 2 4 6 3 9 12 8]
EKG( 5): [1 5 10 2 4 6 3 9 12 8 14 7 21 15 18 16 20 22 11 33 24 26 13 39 27 30 25 35 28 32]
EKG(7): [1 7 14 2 4 6 3 9 12 8]
EKG( 7): [1 7 14 2 4 6 3 9 12 8 10 5 15 18 16 20 22 11 33 21 24 26 13 39 27 30 25 35 28 32]
EKG( 9): [1 9 3 6 2 4 8 10 5 15 12 14 7 21 18 16 20 22 11 33 24 26 13 39 27 30 25 35 28 32]
EKG(10): [1 10 2 4 6 3 9 12 8 14 7 21 15 5 20 16 18 22 11 33 24 26 13 39 27 30 25 35 28 32]


EKG(5) and EKG(7) converge at term 21
EKG(5) and EKG(7) converge at term 21