Hey, @There,
I guess regarding your query you need to see an example which is mentioned below:
Given an array and an integer k, traverse the array and if the element in the array is k, double the value of k and continue traversal. In the end return value of k.
Examples:
Input : arr[] = { 2, 3, 4, 10, 8, 1 }, k = 2
Output :16
First k = 2 is found, then we search for 4
which is also found, then we search for 8
which is also found, then we search for 16.
Input : arr[] = { 2, 4, 5, 6, 7 }, k = 3
Output :3
I hope this helps!!!