Algorithm of 694 - The Collatz Sequence

Problem Description Link

This is a simple problem . Just follow  this stapes:

Step 1:
    Choose an arbitrary positive integer A as the first item in the sequence.
Step 2:
    If A = 1 then stop.
Step 3:
    If A is even, then replace A by A / 2 and go to step 2.
Step 4:
    If A is odd, then replace A by 3 * A + 1 and go to step 2.

[You can use long long int data type ]

Solution Link
image

No comments:

Post a Comment

Write your comment - Share Knowledge and Experience