判断素数的个数的小程序

输入n,判断不超过x的素数的个数最大是多少,所以有可能出现输入20,输出27点多。

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
using namespace std;
#define e 2.718281828459

int main(){
    double n;

    while(scanf("%lf",&n)!=EOF){
        //double temp1=log10(2)/log10(e);
        //double temp2=log10(n)/log10(e);

        //printf("%lf %lf\n",temp1,temp2);
        printf("%lf\n",6*(log10(2)/log10(e))*n/(log10(n)/log10(e)));
    }

    return 0;
}


posted @ 2015-10-12 20:06  buzhidaohahaha  阅读(324)  评论(0编辑  收藏  举报