From e0be0fdf54fcbe5782eda594bed41e20b4042547 Mon Sep 17 00:00:00 2001 From: VISHAL V NAIR <122366926+vishalvnair124@users.noreply.github.com> Date: Tue, 1 Oct 2024 11:01:10 +0530 Subject: [PATCH] Add Odd and Even Check Functions (#165) * Add CheckOdd and CheckEven functions * code style improved * code corrected --- DIRECTORY.md | 2 ++ Maths/CheckEven.php | 13 +++++++++++++ Maths/CheckOdd.php | 13 +++++++++++++ tests/Maths/MathsTest.php | 20 ++++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 Maths/CheckEven.php create mode 100644 Maths/CheckOdd.php diff --git a/DIRECTORY.md b/DIRECTORY.md index 8e2c1b5b..353edbda 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -46,8 +46,10 @@ * [Absolutemin](./Maths/AbsoluteMin.php) * [Armstrongnumber](./Maths/ArmstrongNumber.php) * [Basex](./Maths/BaseX.php) + * [CheckEven](./Maths/CheckEven.php) * [Checkpalindrome](./Maths/CheckPalindrome.php) * [Checkprime](./Maths/CheckPrime.php) + * [CheckOdd](./Maths/CheckOdd.php) * [Eratosthenessieve](./Maths/EratosthenesSieve.php) * [Factorial](./Maths/Factorial.php) * [Fastexponentiation](./Maths/FastExponentiation.php) diff --git a/Maths/CheckEven.php b/Maths/CheckEven.php new file mode 100644 index 00000000..a53b8861 --- /dev/null +++ b/Maths/CheckEven.php @@ -0,0 +1,13 @@ +assertTrue(isEven(2)); + $this->assertTrue(isEven(0)); + $this->assertFalse(isEven(3)); + $this->assertFalse(isEven(17)); + $this->assertTrue(isEven(-4)); + } + public function testIsNumberArmstrong() { $this->assertTrue(isNumberArmstrong(153)); @@ -56,6 +67,15 @@ public function testIsNumberPalindromic() $this->assertFalse(isNumberPalindromic(2468)); } + public function testIsOdd() + { + $this->assertTrue(isOdd(3)); + $this->assertTrue(isOdd(17)); + $this->assertFalse(isOdd(4)); + $this->assertFalse(isOdd(0)); + $this->assertTrue(isOdd(-5)); + } + public function testIsPrime() { $this->assertTrue(isPrime(73));