using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace pm
{
class Primes
{
static void Main(string[] args)
{
int n = 2, totalPrimeNumbers = 1, x;
double sumOfPrimes = 2, average;
while (n <= 100)
{
// test if n is prime
for (x = 2; x < n; x++)
{
if ((n % x) != 0)
{
sumOfPrimes = sumOfPrimes + n;
totalPrimeNumbers++;
// change value of x to end for loop
x = n + 1;
}
}
// increase n by 1 to test next number
n++;
}
Console.WriteLine("Sum - " + sumOfPrimes);
}
}
}
Loading