Find the winner in nim | function to find winner of NIM - game ; case when Alice is winner ; when Bob is winner ; Driver Code
< ? php function findWinner ( $ A , $ n ) { $ res = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) $ res ^= $ A [ $ i ] ; if ( $ res == 0 or $ n % 2 == 0 ) return " Alice " ; else return " Bob " ; } $ A = array ( 1 , 4 , 3 , 5 ) ; $ n = count ( $ A ) ; echo " Winner = " ? >