Add IsEven Algorithm (#4301)

Co-authored-by: BamaCharanChhandogi <b.c.chhandogi@gmailcom>
This commit is contained in:
Bama Charan Chhandogi 2023-08-13 01:36:39 +05:30 committed by GitHub
parent 251157059c
commit 1ef700e850
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View 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;
}
}

View File

@ -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));
}
}