Add IsEven Algorithm (#4301)
Co-authored-by: BamaCharanChhandogi <b.c.chhandogi@gmailcom>
This commit is contained in:
parent
251157059c
commit
1ef700e850
12
src/main/java/com/thealgorithms/bitmanipulation/IsEven.java
Normal file
12
src/main/java/com/thealgorithms/bitmanipulation/IsEven.java
Normal file
@ -0,0 +1,12 @@
|
||||
package com.thealgorithms.bitmanipulation;
|
||||
|
||||
/**
|
||||
* Converts any Octal Number to a Binary Number
|
||||
* @author Bama Charan Chhandogi (https://github.com/BamaCharanChhandogi)
|
||||
*/
|
||||
|
||||
public class IsEven {
|
||||
public static boolean isEven(int number) {
|
||||
return (number & 1) == 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.thealgorithms.bitmanipulation;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class IsEvenTest {
|
||||
@Test
|
||||
void testIsEven() {
|
||||
assertEquals(true, IsEven.isEven(2));
|
||||
assertEquals(true, IsEven.isEven(-12));
|
||||
assertEquals(false, IsEven.isEven(21));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user