Find winner in game of N balls , in which a player can remove any balls in range [ A , B ] in a single move | Function to find the winner of the game ; Stores sum of A and B ; If N is of the form m * ( A + B ) + y ; Otherwise , ; Input ; Function call
function NimGame ( N , A , B ) { let sum = A + B ; if ( N % sum <= A - 1 ) return " " ; else return " " ; } let N = 3 , A = 1 , B = 2 ; document . write ( NimGame ( N , A , B ) + " " ) ;