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.

46 lines
926 B

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