Company: Walmart_12march
Difficulty: medium
Sequence Termination Problem Description We've devised a sequence for any integer N, where the next term is determined by the function: a(n+1) = f(a(n)) = 3 * a(n) + 3 if a(n) is odd a(n+1) = f(a(n)) = a(n)/2 if a(n) is even The sequence starts with a(0) = N . The sequence terminates if for some element a(i) , its value becomes 1 . Given any integer N, can you predict if the sequence terminates or not? Input Format A single integer representing N. Output Format Print "YES" if the sequence terminates otherwise, print "NO". Note: The output is case-sensitive. Examples Example 1: Input: N = 2 Output: YES Explanation: For N=2, the sequence is a(0)=2 (even) → a(1)=2/2=1 . The sequence is 2, 1 . Since a(1) is 1 , the sequence terminates. Example 2: Input: N = 3 Output: NO Explanation: For N=3, the sequence is a(0)=3 (odd) → a(1)=3*3+3=12 . a(1)=12 (even) → a(2)=12/2=6 . a(2)=6 (even) → a(3)=6/2=3 . a(3)=3 (odd) → a(4)=3*3+3=12 . The sequence becomes 3, 12, 6, 3, 12,