判断素数的个数的小程序

来源:互联网 发布:java编程输出金字塔 编辑:程序博客网 时间:2024/04/29 12:57

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

#include<stdio.h>#include<string.h>#include<math.h>#include<iostream>using namespace std;#define e 2.718281828459int 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;}


0 0
原创粉丝点击