Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int a_num(int a_min, int a_max, int * base, int base_idx, int m){
- int i;
- int z = 1;
- int al = a_min-1;
- int ah = a_max - 1;
- for(i = 0; i < base_idx; i++){
- z *= base[i];
- }
- if(m%4 == 0) z *= 2;
- int al_mod = al % z;
- if(al_mod != 0) al += (z - al_mod);
- ah -= ah % z;
- return (ah - al) / z + 1;
- }
- int c_comb(int c_min, int c_max, int * base, int base_idx){
- int fb = c_max - not_prime(c_max, base, base_idx);
- int fa1 = c_min - 1 - not_prime(c_min - 1, base, base_idx);
- return fb - fa1;
- }
- //computes the number of not prime numbers
- int not_prime(int c, int * base, int base_idx){
- int my_sum = 0;
- int product = 1;
- int sign;
- int i, j, tmp;
- unsigned int comb[2];
- int p = (int) pow(2,base_idx);
- comb[0] = 0;
- for(i = 1; i < p; i++){
- comb[0]++;
- sign = pow2(*comb) ? 1 : -1;
- for(j = 0; j < base_idx; j++){
- product *= test_bit(comb, j) ? base[j] : 1;
- tmp = test_bit(comb, j) ? 1 : 0;
- }
- if(!product) printf("ERROR, product 0\n");
- my_sum += sign * (c/product);
- product = 1;
- }
- return my_sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment