@Dave Logic is good. could not understand how does it works. Could you please explain
On Tue, Jun 22, 2010 at 9:16 PM, Dave <dave_and_da...@juno.com> wrote: > Let m = 2^k - 1. > To check divisibility of n by m, > 1. If n is zero, return true. > 2. If n is negative, replace n with -n. > 3. While n > m, replace n with (n >> k) + (n & m). > 4. Return (n == m). > > This is equivalent to the "casting out nines" algorithm to determine > if a number is a multiple of 9. > > Dave > > On Jun 22, 3:37 pm, divya <sweetdivya....@gmail.com> wrote: > > u are given any binary no...... u have to check its divisbility by > > 3,7,15, > > 31......(any no. of the form 2^x-1) > > .u cant use any division > > and modulo operator for that..... > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.