text: Reduce the array to a single element with the given operation | Java implementation of the approach ; Function to return the final element ; Driver code
code: class OddPosition { public static long getFinalElement ( long n ) { long finalNum ; for ( finalNum = 2 ; finalNum * 2 <= n ; finalNum *= 2 ) ; return finalNum ; } public static void main ( String [ ] args ) { int N = 12 ; System . out . println ( getFinalElement ( N ) ) ; } }