I will run a loop that'll subtract 16 from the number. If result is zero than it is divisible else if it goes less than zero than its is not.

View Allnum of num

8 Answers

▲

0

▼

I will run a loop that'll subtract 16 from the number. If result is zero than it is divisible else if it goes less than zero than its is not.

▲

0

▼

Bit wise right shift four times, if integer then divisible.

▲

0

▼

for(int i=0;in)

{

break;

}

//number is not divisible by 16

//which will be decided by the flag

}

}

▲

0

▼

Sorry for that incompleted answer ! I want to say that simply use a loop upto n and multiply each number with 16 and store in a variable and then go for a check if it is matched by n or not.

If matched then flag==true else break;

▲

0

▼

If a number is divisible by 2^n, do bitwise right shift n times and then bitwise left shift n times to get back the same number.

▲

0

▼

if(16>>4 == 0 )

True;

else

False

▲

0

▼

The above condition should be 1 instead of 0.

if(16>>4 == 1 )

True;

else

False

To comment on this, Sign In or Sign Up.

Would you like us to review something? Please describe the problem with this {0} and we will look into it.

Your feedback has been sent to the team and we'll look into it.

should do using bit-wise operators