Hi, What is the algorithm to compute the sum of primes? Found this challenge at rankk.org. Got stuck Could someone help?
int n; //the number till which u need to compute primes int factors; //counts the number of factors for(int i=0;i<n;i++) { for(int j=1;j<i;j++) { if(i%j==0) { factors++; } if(factors==2) { break; } } factors=0; sum+=i; } cout<<sum; hope this works for you ps- the code is written in c++....did not have the patience to write the algo