谁还没个明天 2018-11-02 00:35 采纳率: 66.7%
浏览 215

求整除度的有效方法

Professor says this isn't a efficient algorithm to check whether the number is divisible by a number from 100,000-150,000. I'm having trouble finding a better way. Any help would be appreciated.

unsigned short divisibility_check(unsigned long n){
    unsigned long i;
    for(i=100000; i<=150000;i++){
        if(n%i == 0){
            return 0;
        }
    }
    return 1;
}

转载于:https://stackoverflow.com/questions/53111230/efficient-way-to-find-divisibility

  • 写回答

0条回答 默认 最新

    报告相同问题?