Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- long i,j,x,m,n,k,q;
- int main() {
- m = 0;
- scanf("%li %li",&i,&j);
- if (i > j) {
- q =i ;
- i = j;
- j = q;
- }
- for (x = i;x < j+1;x++) {
- k = 0;
- n = x;
- while (n != 1) {
- k+=1;
- if (n % 2 == 0) {
- n = n/2;
- }
- else
- {
- n = 3*n+1;
- }
- }
- k+=1;
- if (k>m) {
- m = k;
- }
- }
- printf("%li %li %li\n",i,j,m);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment