음...이것도 어딘가에서 봤던 문제다.
500개 이상의 약수를 가지는 첫번째 숫자를 찾아내는 문제.

#include<stdio.h>
#include<stdlib.h>

int numberOfFactors(unsigned long long );

int main(){

    unsigned long long i=3ll;
    while(1){
        printf("i=%lld\t",i);
        if(numberOfFactors(i*(i+1ll)/2ll)>500){
            printf("%lld has more 500 divisors\n",i*(i+1ll)/2ll);
            exit(1);
        }
        i++;
    }

return 1;
}

int numberOfFactors(unsigned long long p){
    unsigned long long n,i;
    n=0ll;
    for(i=1ll;i<((p/2ll)+1ll);i++){
        if(p%i==0ll){
//        printf("%lld,",i);
        n++;
        }
    }
    printf("n=%lld\tp=%lld\n",n,p);
    return n;
}
by snowall 2008. 10. 13. 21:42