Skip to content

Commit 1ef700e

Browse files
BamaCharanChhandogiBamaCharanChhandogi
andauthored
Add IsEven Algorithm (TheAlgorithms#4301)
Co-authored-by: BamaCharanChhandogi <b.c.chhandogi@gmailcom>
1 parent 2511570 commit 1ef700e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.thealgorithms.bitmanipulation;
2+
3+
/**
4+
* Converts any Octal Number to a Binary Number
5+
* @author Bama Charan Chhandogi (https://github.com/BamaCharanChhandogi)
6+
*/
7+
8+
public class IsEven {
9+
public static boolean isEven(int number) {
10+
return (number & 1) == 0;
11+
}
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.thealgorithms.bitmanipulation;
2+
3+
import static org.junit.jupiter.api.Assertions.*;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
class IsEvenTest {
8+
@Test
9+
void testIsEven() {
10+
assertEquals(true, IsEven.isEven(2));
11+
assertEquals(true, IsEven.isEven(-12));
12+
assertEquals(false, IsEven.isEven(21));
13+
}
14+
}

0 commit comments

Comments
 (0)