Maximum number of multiplication by 3 or division by 2 operations possible on an array | C # program for the above approach ; Function to count maximum number of multiplication by 3 or division by 2 operations that can be performed ; Stores the maximum number of operations possible ; Traverse the array arr [ ] ; Iterate until arr [ i ] is even ; Increment count by 1 ; Update arr [ i ] ; Return the value of Count as the answer ; Driver Code ; Given Input ; Function Call
using System ; using System . Collections . Generic ; class GFG { static int maximumTurns ( int [ ] arr , int N ) { int Count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { while ( arr [ i ] % 2 == 0 ) { Count ++ ; arr [ i ] = arr [ i ] / 2 ; } } return Count ; } public static void Main ( ) { int [ ] arr = { 5 , 2 , 4 } ; int N = arr . Length ; Console . Write ( maximumTurns ( arr , N ) ) ; } }