void sieve(void) { int idx = 1; hash = 5381; print_prime(idx++, 2); for (int i = 0; i < BITMAP_SIZE; i++) { if (bitmap_get(i)) continue; print_prime(idx++, 3+2*i); for (int j = 2*(3+2*i);; j += 3+2*i) { if (j%2 == 0) continue; int k = (j-3)/2; if (k >= BITMAP_SIZE) break; bitmap_set(k); } } print_str("checksum: "); print_hex(hash, 8); if (hash == 0x1772A48F) { print_str(" OK\n"); } else { print_str(" ERROR\n"); __asm__ volatile ("sbreak"); } }
int main(void) { int n, i, m; scanf("%d%d", &m, &n); printf(" %d 与 %d 之间的素数为:\n", m, n); print_prime(m, n); return 0; }
int main() { int n; calc_prime(); calc_prime_index(); while(scanf("%d",&n) != -1) { if (prime_index[n].count == 0) { printf("0\n"); } else { printf("%d\n",prime_index[n].count); print_prime(n); } } return 0; }
int main(int argc, const char * argv[]) { // char str[] = "aabcbc"; // printf("str=%s\n", str); // 删除一个字符串当中的第一个符合要求的子串 // del_substr(str, "abc"); // printf("after del_substr(str, \"abc\"),str=%s\n", str); // reverse_str(str); // printf("after reverse_str(str),str=%s\n", str); char *result =(char *)malloc(SIZE * sizeof(char)); memset(result, 1, SIZE * sizeof(char)); // for (int i = 0; i < SIZE; i++) // { // printf("%i", *(result + i)); // } find_all_prime(result, SIZE); print_prime(result, SIZE); }
int main(int argc, char *argv[]) { char *prime; BIGNUM *num_tmp; long int num_bits = 0; if(argc >= 2 && argv[1]) num_bits = atol(argv[1]); else num_bits = 1024; printf("Prime generator by (c) 2004 Paolo Ardoino < *****@*****.** >\n usage: ./genprimes [num_bits]\nGenerating %ld bits primes.\nWait…\n",num_bits); num_tmp = BN_new(); for (;;) { BN_generate_prime(num_tmp,num_bits,1,NULL,NULL,status,NULL); prime = (char *)malloc(BN_num_bytes(num_tmp)); prime = BN_bn2dec(num_tmp); print_prime(prime); free(prime); } BN_free(num_tmp); }