| 1 |
#include <cl_number.h>
|
| 2 |
#include <cl_io.h>
|
| 3 |
#include <cl_integer.h>
|
| 4 |
#include <stdlib.h>
|
| 5 |
#include <string.h>
|
| 6 |
#include <cl_timing.h>
|
| 7 |
|
| 8 |
int main (int argc, char * argv[])
|
| 9 |
{
|
| 10 |
int limit = 1000;
|
| 11 |
int repetitions = 1;
|
| 12 |
while (argc >= 3) {
|
| 13 |
if (!strcmp(argv[1],"-r")) {
|
| 14 |
repetitions = atoi(argv[2]);
|
| 15 |
argc -= 2; argv += 2;
|
| 16 |
continue;
|
| 17 |
}
|
| 18 |
if (!strcmp(argv[1],"-l")) {
|
| 19 |
limit = atoi(argv[2]);
|
| 20 |
argc -= 2; argv += 2;
|
| 21 |
continue;
|
| 22 |
}
|
| 23 |
break;
|
| 24 |
}
|
| 25 |
if (argc < 1)
|
| 26 |
exit(1);
|
| 27 |
|
| 28 |
fprint(cl_stderr, "Limit: ");
|
| 29 |
fprintdecimal(cl_stderr, limit);
|
| 30 |
fprint(cl_stderr, "\n");
|
| 31 |
fprint(cl_stderr, "Number of repetitions: ");
|
| 32 |
fprintdecimal(cl_stderr, repetitions);
|
| 33 |
fprint(cl_stderr, "\n");
|
| 34 |
|
| 35 |
{ CL_TIMING;
|
| 36 |
for (int rep = repetitions; rep > 0; rep--)
|
| 37 |
{ cl_I u = 1, v = 1, p = 1, q = 1;
|
| 38 |
for (int k = 1; k <= limit; k++)
|
| 39 |
{ cl_I w = u+v;
|
| 40 |
u = v; v = w;
|
| 41 |
p = p*w; q = lcm(q,w);
|
| 42 |
}
|
| 43 |
}
|
| 44 |
}
|
| 45 |
|
| 46 |
}
|