UVA 694 - The Collatz Sequence UVA • Sep 1, 2020 Problem PDFSolution:#include #include #include #include #include #include #include #include #include #include #include #include #define ll long long #define sc scanf #define pf printf #define Pi 2*acos(0.0) using namespace std; int main() { ll n,e,c,a; int no=0; while(sc("%lld %lld",&n,&e)==2) { if(n<0&&e<0) break; c=0; a=n; while(n<=e) { if(n==1) { c++; break; } else if(n%2==0) { c++; n/=2; } else if(n%2==1) { c++; n=n*3+1; } } pf("Case %d: A = %lld, limit = %lld, number of terms = %lld\n", ++no,a,e,c); } return 0; } https://github.com/Shipu/OnlineJudgeProblemSolutionWithCPlusPlus/tree/master/uva/694/694.cpp Tags UVA Competitive Programming Shipu Ahamed Recommended for you UVA UVA 913 - Joana and the Odd Numbers 4 years ago • 1 min read UVA UVA 871 - Counting Cells in a Blob 4 years ago • 3 min read UVA UVA 866 - Intersecting Line Segments 4 years ago • 3 min read