Friday, February 10, 2012

Java program to find the divisibility by 2 without using mod(%)

/**to find divisibility by 2 without using "%"
*/
public class Shivam
{
public static boolean check(int a)
{
if(a/2.0-a/2==0)
return true;
return false;

}
}

4 comments:

  1. hey this is really funny..
    Why actually do u no want to use the mod???

    ReplyDelete
  2. Why can't I open the Skin Care providing sits???
    :(
    They seem interesting to me..
    Google's ads are not working properly on ur site dude..

    ReplyDelete
  3. Good post, this is a popular interview question and there are multiple ways of doing it

    1) using bit shit operator
    2) using divide operator
    3) using % operator
    4) using ! operator.

    keep it up.

    Javin
    How HashMap works in Java

    ReplyDelete