int main(){
    ll n, i, primesc, q;
    primesc=0;
    scanf("%lld %lld", &n, &q);
    compute_sieve(n);
    printf("%lld\n", primes);
    while(q--){
        scanf("%lld", &n);
        printf("%d\n", is_prime(n));
    }
    return 0;
}
Beispiel #2
0
int compute_prime_factors(long double a,int sz){
    
    double primes[sz];
    compute_sieve(primes,sz);
    int res[sz]; /*store the result here*/
    int i ;/*index of primes array*/
    int pos = 0 ; /*position in result array */

    for( i = 2 ;i < sz ; i++){ 
        if(primes[i] > 0 ){
            while(fmod(a,primes[i]) == 0 ){
                a = a / primes[i];
                pos++;
            }
            res[i] = pos ;
            pos = 0 ;
            if(res[i] > 0 ){
                printf("You need %d %.0f(s)\n",res[i],primes[i] );
            }
        }
    }
    return 0 ;
}