Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
primes
#include <bits/stdc++.h> using namespace std; int manan(int n) { int k=n/68; return n/(log(n)+log(3.10))+k; } int SieveOfEratosthenes(int n) { int count=0; bool prime[n + 1]; memset(prime, true, sizeof(prime)); for (int p = 2; p * p <= n; p++) { if (prime[p] == true) { for (int i = p * p; i <= n; i += p) prime[i] = false; } } for (int p = 2; p <= n; p++) if (prime[p]) { count++; } return count; } int main() { vector<int>error(10000); error[0]=-1; error[1]=-1; for(int i=2; i<=10000; i++) { error[i]=SieveOfEratosthenes(i)-manan(i); } int Max=INT_MIN; for(int i=2; i<=10000; i++) { cout<<error[i]<<endl; Max=max(Max, error[i]); } cout<<Max; return 0; }
run
|
edit
|
history
|
help
0
new
Testing C++
char
Test 9(2021)
Samosa
project: bank account
c++ car racing game
ONP
FuktExam.cpp
Kadane's Algorithm