UVA 694
#include<iostream> using namespace std; int main() { int flag=1; long m,n; while(cin>>m>>n) { if(m==-1&&n==-1) break; long temp=1; cout<<"Case "<<flag<<": A = "<<m<<", limit = "<<n<<", number of terms = "; while(m>1) { if(m%2) m=m*3+1; else m/=2; if(m>n)break; temp++; } cout<<temp<<endl; flag++; } return 0; }