Advertisement
wandrake

Untitled

Oct 3rd, 2012
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdint.h>
  3.  
  4. int main(void) {
  5.     uint32_t min, max;
  6.     uint32_t i, temp, vmax, count;
  7.  
  8.     while (scanf("%d %d\n", &min, &max) == 2) {
  9.         vmax = 0;
  10.         for (i = min; i <= max; i++) {
  11.             temp = i;
  12.             count = 1;
  13.             while(temp != 1) {
  14.                 if (temp % 2 == 0) temp = temp / 2;
  15.                 else temp = 3 * temp + 1;
  16.                 count++;
  17.             }
  18.             if (count > vmax) vmax = count;
  19.         }
  20.         printf("%d %d %d\n", min, max, vmax);
  21.     }
  22.  
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement