You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
863 B

25 years ago
25 years ago
  1. #include <cln/number.h>
  2. #include <cln/io.h>
  3. #include <cln/integer.h>
  4. #include <cstdlib>
  5. #include <cstring>
  6. #include <cln/timing.h>
  7. using namespace std;
  8. using namespace cln;
  9. int main (int argc, char * argv[])
  10. {
  11. int limit = 1000;
  12. int repetitions = 1;
  13. while (argc >= 3) {
  14. if (!strcmp(argv[1],"-r")) {
  15. repetitions = atoi(argv[2]);
  16. argc -= 2; argv += 2;
  17. continue;
  18. }
  19. if (!strcmp(argv[1],"-l")) {
  20. limit = atoi(argv[2]);
  21. argc -= 2; argv += 2;
  22. continue;
  23. }
  24. break;
  25. }
  26. if (argc < 1)
  27. exit(1);
  28. cerr << "Limit: " << limit << endl;
  29. cerr << "Number of repetitions: " << repetitions << endl;
  30. { CL_TIMING;
  31. for (int rep = repetitions; rep > 0; rep--)
  32. { cl_I u = 1, v = 1, p = 1, q = 1;
  33. for (int k = 1; k <= limit; k++)
  34. { cl_I w = u+v;
  35. u = v; v = w;
  36. p = p*w; q = lcm(q,w);
  37. }
  38. }
  39. }
  40. }