How do I write a function summing the primes to two million?
>>8806907
get the list of the first two million primes
add them up
done
>>8806907
sieve, sum
>>8806907
>Create a sieve
>Find all the primes up to 2 million
>Put them in a list, or your data structure of choice
>Sum
Easy.
This is like five lines of code lmao
>>8806907
#include <iostream>
#include <vector>
int main(){
std::vector<bool> primes;
primes.resize(2000001);
primes.flip();
primes[0]=false;
primes[1]=false;
unsigned long long sum=0;
for(size_t i = 2; i<=2000000; i++){
if(primes[i]){
sum+=i;
for(size_t j=i*i; j<=2000000; j+=i){
primes[j]=false;
}
}
}
std::cout<<sum;
}
142913828922
>>8806927
Lmao
Problem 10 and already tapped out.
https://projecteuler.net/problem=10
>>8806917
you dont see anything wrong with this??
[math] \sum_{k=1}^{2000000} p_k [/math] where [math] p_k [/math] is the kth prime. Easy OP :^)
where did this 2 million primes meme come from? I suppose it's some new "smart person" movie or tv show
>>8808328
>https://projecteuler.net/problem=10
>>8806907
Www.4chan.org/g
>>8806907
I'm not doing your homework
let a be sum of all primes to two million
f(x)=a