int IsDivisible(int n){

if(n<0){
n=-n;
}

if(n==0 || n==7){
return 1;
}

if(n<10){
return 0;
}

int a;
int b;

a=n/10;
b=(n-a*10);

//printf("\na: %d and b : %d",a,b);

return IsDivisible(a-2*b);





}
int main(){

int n=616;

int result=IsDivisible(n);

if(result){
printf("\n%d is divisible by 7",n);
}else{
printf("\nNot divisible");
}


return 0;
}
Esempio n. 3
0
void CyclRatFunct::simplifyCRF(){
// cancels factors 1-t^i from the denominator that appear there explicitly
// (and not just as factors of 1-t^j for some j)

    SparsePolyRing R=owner(num);
    long nd=denom.size();
    for(long i=1;i<nd;i++)
    {
        while(denom[i]>0)
        {
            if(!IsDivisible(num,1-power(indets(R)[0],i)))
                break;
            num/=1-power(indets(R)[0],i);
            denom[i]--;
        }
    }
}