Chinaunix首页 | 论坛 | 博客
  • 博客访问: 387753
  • 博文数量: 55
  • 博客积分: 1907
  • 博客等级: 上尉
  • 技术积分: 869
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-04 19:30
文章分类

全部博文(55)

文章存档

2011年(32)

2010年(23)

分类: C/C++

2010-11-28 19:13:04

/*
 * The changes needed to the problem are minor:Istead of printing rhe primes,they are counted.
 * 2010-11-20
 */
/*
 * Go through the entire sieve now and count how many primes there are
 * per thousand numbers.
 */
 

n_primes = 1;
limit = 1000;

for( bit_number = 0, number = 3;
    number <= MAX_VALUE;
    bit_number += 1, number += 2 )
{
        if( test_bit( sieve, bit_number ) )
        {
            printf( "%d-%d: %d\n", limit - 1000, limit, n_primes );
            n_primes = 0;
            limit += 1000;
        }
        if( test_bit( sieve, bit_number ) )
            n_primes += 1;
}
printf( "%d-%d: %d\n", limit - 1000, limit, n_primes );


阅读(1278) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~