private string SolveProblem2() { double loopEnd = 200000, numCurrent = 200000; BigInteger sum = new BigInteger("0"); for (int i = 0; i < loopEnd ; i++, numCurrent++) { SolveProblem2_1(numCurrent, ref sum); } return sum.ToString(); //returns final result } private void SolveProblem2_1(double numCurrent, ref BigInteger sum) { int j = 2; double res = 0; while (j < numCurrent) { res = numCurrent % j; if (res == 1) { j++; } else { break; } } if (j == numCurrent) { sum = sum.add(new BigInteger(numCurrent.ToString())); } }
if (numCurrent % j== 0)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)