#include<stdio.h>

int main() {
    int num,tmp=1;
    printf("Enter the number \n");
    scanf("%d",&num);

    while(num>9) {
        while(num>tmp)
            tmp=tmp<<1;
        tmp>>1;
        num=num-tmp;
        tmp=1;
    }
    if(num==9 || num==6 || num==3)
        printf("\nNumber divisible by 3");
    else
        printf("\nNumber is not divisible by 3");
    return 0;
}

On Aug 14, 12:45 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)

--~--~---------~--~----~------------~-------~--~----~
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