Advertisement
palmerstone

Untitled

Jun 23rd, 2011
497
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <stdlib.h>
  4. #include <ctype.h>
  5. #include <string.h>
  6.  
  7. int main()
  8. {
  9. int t, i, j, k, l, a, b, c, d, x, y, z, p, q, r, n, m, flag, count;
  10. int ar[1000], ar2[1000];
  11.  
  12. ar[0] = 2, ar[1] = 3, ar[2] = 5, ar[3] = 7, ar[4] = 11;
  13.  
  14. for (j = 5; j < 800; j++)
  15. {
  16. n = ar[j - 1];
  17. for (k = n + 2; ;k = k + 2)
  18. {
  19. flag = 0;
  20. for (l = 0; l < j; l++)
  21. {
  22. if (ar[l] > k) {flag = 2; break;}
  23. if (k % ar[l] == 0) flag = 1;
  24. }
  25. if (flag == 0)
  26. {
  27. ar[j] = k;
  28. break;
  29. }
  30. }
  31. }
  32.  
  33. for (; ;)
  34. {
  35. scanf("%d", &n);
  36. if (n == 0) break;
  37.  
  38. flag = 0, count = 0, x = n;
  39. for (j = 0; ;)
  40. {
  41. if (ar[j] > n)
  42. {
  43. break;
  44. }
  45.  
  46. if (n % ar[j] == 0 && flag == 0)
  47. {
  48. n = n / ar[j];
  49. flag = 1;
  50. count++;
  51. }
  52. else
  53. {
  54. j++;
  55. flag = 0;
  56. }
  57. }
  58.  
  59. for (j = 0; ;j++)
  60. {
  61. if (ar[j] > n) break;
  62.  
  63. if (ar[j] == n)
  64. {
  65. count++;
  66. }
  67. }
  68. printf("%d : %d\n", x, count);
  69. }
  70. return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement