Find the remainder when N is divided by 4 using Bitwise AND operator | Java implementation to find N modulo 4 using Bitwise AND operator ; Driver code ; Function to find the remainder ; Bitwise AND with 3 ; return x
class Main { public static void main ( String [ ] args ) { int N = 43 ; int ans = findRemainder ( N ) ; System . out . println ( ans ) ; } public static int findRemainder ( int n ) { int x = n & 3 ; return x ; } }