text: Reduce the array to a single element with the given operation | C ++ implementation of the approach ; Function to return the final element ; Driver code
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; long getFinalElement ( long n ) { long finalNum ; for ( finalNum = 2 ; finalNum * 2 <= n ; finalNum *= 2 ) ; return finalNum ; } int main ( ) { int N = 12 ; cout << getFinalElement ( N ) ; return 0 ; }