brother how do u get the digits of number ???u use % and / rite??

On Fri, Aug 14, 2009 at 7:28 PM, Yogesh Aggarwal <
yogesh.aggarwa...@gmail.com> wrote:

> (CORRECTED ALGO.)
> We can do like dis...
> - add all d digits of the no.
> - if the result is MORE than 10, add all the digits of the result again.
> - continue step2 if the result is still MORE than 10
> - if the result is either 0, 3 , 6 or 9 den the no. is divisible by 3.
>
> example 1 :
> num = 12345
> sum1 = 15 (sum > 10)
> sum2 = 6
> since sum < 10, we stop here and since final sum = 6 ....so the given no.
> is divisible by 3
>
>
> On Fri, Aug 14, 2009 at 7:25 PM, Yogesh Aggarwal <
> yogesh.aggarwa...@gmail.com> wrote:
>
>> (CORRECTED ALGO.)
>> We can do like dis...
>> - add all d digits of the no.
>> - if the result is MORE than 10, add all the digits of the result again.
>> - continue step2 if the result is still less than 10
>> - if the result is either 0, 3 , 6 or 9 den the no. is divisible by 3.
>>
>> example 1 :
>> num = 12345
>> sum1 = 15 (sum > 10)
>> sum2 = 6
>> since sum < 10, we stop here and since final sum = 6 ....so the given no.
>> is divisible by 3
>>
>> On Fri, Aug 14, 2009 at 7:20 PM, santhosh venkat <
>> santhoshvenkat1...@gmail.com> wrote:
>>
>>> given a number n
>>>  u can get the quotient when it is divided by 4 using right shift 2 times
>>>
>>> like n >> 2 this ll give u quotient(q)
>>> u can get the remainder by subtracting 4 * q from n which will give  the
>>> remainder when divided by 4
>>>
>>> by doing this u ll express n as n = 4q + r  = 3q + (q+r)
>>> in this already 3q which is divisible by 3 .. u can apply the same logic
>>> recursively to q+r and return the remainder obtained for q+r..
>>>
>>>
>>> On Fri, Aug 14, 2009 at 7:11 PM, Yogesh Aggarwal <
>>> yogesh.aggarwa...@gmail.com> wrote:
>>>
>>>> @arun : we are not supposed to use / operator. but in ur algo u r using
>>>> / or %  has to be used to check wether the diff is divisible by 3.
>>>> We can do like dis...
>>>> - add all d digits of the no.
>>>> - if the result is less than 10, add all the digits of the result again.
>>>> - continue step2 if the result is still less than 10
>>>> - if the result is either 0, 3 , 6 or 9 den the no. is divisible by 3.
>>>>
>>>> example 1 :
>>>> num = 12345
>>>> sum1 = 15 (sum > 10)
>>>> sum2 = 6
>>>> since sum < 10, we stop here and since final sum = 6 ....so the given
>>>> no. is divisible by 3
>>>>
>>>>
>>>> On Fri, Aug 14, 2009 at 3:09 PM, Arun N <arunn3...@gmail.com> wrote:
>>>>
>>>>> take an number find its binary
>>>>> add all odd bits and even bits seperately
>>>>> now check if the difference is divisible by 3
>>>>> if yes it is
>>>>> say 6 110  ----->  1+0 - 1 =0
>>>>> 9 1001 -----> 1+0 - 0+1 = 0
>>>>> 12 1100  ------> 1+0 - 1+0  = 0
>>>>> Arun,
>>>>>
>>>>> On Fri, Aug 14, 2009 at 1:15 PM, richa gupta <richa.cs...@gmail.com>wrote:
>>>>>
>>>>>>
>>>>>> can we check the divisibility of a given number by 3 withoutusing
>>>>>> operators like '/' or '%'.
>>>>>> I want the efficient solution to this problem ..
>>>>>>
>>>>>> can someone help ??
>>>>>> --
>>>>>> Richa Gupta
>>>>>> (IT-BHU,India)
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Potential is not what U have, its what U think U have!!!
>>>>> It is better to worn out than rust.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Best Wishes & Regards
>>>> Thank You
>>>> Yogesh Aggarwal
>>>> B.Tech(IT),
>>>> University School of Information Technology
>>>> GGS Indraprastha University
>>>> Delhi
>>>> mailto: yogesh.aggarwa...@gmail.com
>>>> #9990956582
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>> --
>> Best Wishes & Regards
>> Thank You
>> Yogesh Aggarwal
>> B.Tech(IT),
>> University School of Information Technology
>> GGS Indraprastha University
>> Delhi
>> mailto: yogesh.aggarwa...@gmail.com
>> #9990956582
>>
>
>
>
> --
> Best Wishes & Regards
> Thank You
> Yogesh Aggarwal
> B.Tech(IT),
> University School of Information Technology
> GGS Indraprastha University
> Delhi
> mailto: yogesh.aggarwa...@gmail.com
> #9990956582
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@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
-~----------~----~----~----~------~----~------~--~---

Reply via email to