Have you ever wondered if a number is even or odd? Well, those times are over! With this implementation of isEven()
you can once and for all determine if a number is even! And it doesn't end here! I also included isOdd()
so you can be 100% sure when a number is odd!
- Clone this repository (if you haven't done so already).
git https://github.com/Roiqk7/isEven
- Default
isEven.cpp
supports integers from-600420
to600420
(because GitHub doesn't allow for larger files). If that's fine with you, you can stop there. Otherwise, if you want more integers, follow the rest of this tutorial. - Open your terminal.
- Go into the repo directory.
- Run
python3 build.py
. That will makeisEven.cpp
support integers all the way up to 100 million. This action takes around 1 minute on MacBook M2. To learn how to change this ceiling, click here! - Everything is set and done!
For example, usage refers to example.cpp.
- Follow the steps in Installation (if you haven't done so already).
- Open your terminal.
- Go into the repo directory.
- Run
g++ -std=c++17 -o example example.cpp isEven.cpp isOdd.cpp evenVector.cpp && ./example
- Find out if your favorite number is even or odd!
How do I change the ceiling of isEven.cpp
? Easily!
- Open build.py in your text editor of choice.
- At line 8, notice the variable
totalIterations
. - Change it's value to whatever you deem necessary!
This repository is mainly used to determine if a number is even or odd using isEven()
function defined in isEven.cpp
and isOdd()
function defined in isOdd.cpp
. These functions then store a LOT of numbers to check whether the desired number is even or odd. Keep in mind that the functions only support numbers defined within them.
Also we have EvenVector
class which adds a simple to use data structure to determine if a number is even or odd. Simply use the overloaded []
operator with a number you want to know is even or not and a proper boolean value will be returned to you as output.
Well... it's not really recommended. Look at the image bellow to see exactly how totalIterations = 1 Billion
is large. Also, it takes around 10 minutes to build. I tried rewriting build.py
in C++, but it didn't improve the performance at all.