1. C, Tobias Fuchs

/* Author: Tobias Fuchs
* Problem: 694
* Verdict: Accepted
* Runtime: 0.04
*/

#include<stdio.h>

unsigned int collatz_rounds(unsigned int n, unsigned int limit)
{
unsigned int count = 0;
do {
count++;
if(n % 2) {
n = 3 * n + 1;
if(n > limit) { return count; }
}
else { n /= 2; }
} while(n != 1);
return count+1;
}

int main(int argc, char * const argv[])
{
int n, limit, count;
unsigned int terms;
count = 0;
while(1) {
count++;
scanf("%d %d", &n, &limit);
if(n < 0 && limit < 0) return 0;
terms = collatz_rounds(n, limit);
printf("Case %d: A = %d, limit = %d, number of terms = %d\n", count, n, limit, terms);
}
}