Algo-Phantoms / Algo-Tree

Algo-Tree is a collection of Algorithms and data structures which are fundamentals to efficient code and good software design. Creating and designing excellent algorithms is required for being an exemplary programmer. It contains solutions in various languages such as C++, Python and Java.
MIT License
363 stars 617 forks source link

Check even or odd without using arithmetic operator in CPP/Java ? #1319

Open vinc3nati opened 3 years ago

vinc3nati commented 3 years ago

Is your feature request related to a problem? Please describe. There are many ways to find if a number is even or odd but before moving into technical details on finding even and odd number in Java let's what is even and odd number in terms of Mathematics. Any number which is completely divisible by 2 is called even number while number which is not completely divisible by 2 is called odd number

Common approach is using Modulo(%) operator but we can use Bitwise AND(&) for that.

Describe the solution you'd like In binary format, the even number has there LSB always zero while the odd number has there LSB as 1 by using this information and bitwise & operator we can find if a number is even or odd in Java.

Do you want to work on it Yes I want to work on it and I can do it in JAVA as well as C++.

@dheerajkotwani @tarun26091999 @anubhavitis @dheerajkotwani
This issue is created under GSSOC21

pandeydhruv2001 commented 3 years ago

I would like to work in C++, please assign me this issue.

vinc3nati commented 3 years ago

I have already implemented it , just waiting for the confirmation of the admin. So it would be assigned to me.

shubhidua commented 3 years ago

I would like to contribute to the above problem in java as I am a participant of GSSOC'21. Kindly assign this to me.