Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int numbers_game(int min, int max)
  4. {
  5. int counter, c = min;
  6.  
  7. if (max - min == 1) return min * max;
  8. if (min == 1)
  9. {
  10. min = 1;
  11. counter = 1;
  12. while (min != max)
  13. {
  14. min += 1;
  15. if (counter % min != 0)
  16. {
  17. if (min % 2 == 0) counter *= 2;
  18. else if (min % 3 == 0) counter *= 3;
  19. else counter *= min;
  20. }
  21. }
  22.  
  23. return counter;
  24. }
  25. else
  26. {
  27. counter = max;
  28. while (1)
  29. {
  30. min = c;
  31. while (min != max + 1)
  32. {
  33. if (counter % min != 0) break;
  34. if (min == max ) return counter;
  35. min += 1;
  36. }
  37. counter += max;
  38. }
  39. }
  40. }
  41.  
  42. int main(void)
  43. {
  44. int min, max;
  45.  
  46. scanf("%d%d", &min, &max);
  47. printf("%d", numbers_game(min, max));
  48.  
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement