What is proof for finding remainder(%) when n divide by k, if k is power of two.

Revision en2, by Kaleab_Asfaw, 2020-07-27 13:49:49

For any integer n and where k is power of 2,

n % k = n & (k-1)

Example

I wasn't able to proof this statement, how could it be proofed without taking number as example?

Thanks in Advance!

Tags #modulo, #bitwise

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Kaleab_Asfaw 2020-07-27 13:49:49 235 Tiny change: 'oofed with out taking' -> 'oofed without taking'
en1 English Kaleab_Asfaw 2020-07-27 13:37:18 250 Initial revision (published)