计算素数
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Program p = new Program();
p.sump();
}
public void sump()
{
int sum = 0;
for (int i = 2; i < 100; i++)
{
if (this.isZS(i) == 1)
{
Console.WriteLine(i);
sum += i;
}
}
Console.WriteLine(sum);
}
public int isZS(int Num)
{
for (int i = 2; i <= Num / 2; i++)
{
if (Num % i == 0)
{
return 0;
}
}
return 1;
}
}
}
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Program p = new Program();
p.sump();
}
public void sump()
{
int sum = 0;
for (int i = 2; i < 100; i++)
{
if (this.isZS(i) == 1)
{
Console.WriteLine(i);
sum += i;
}
}
Console.WriteLine(sum);
}
public int isZS(int Num)
{
for (int i = 2; i <= Num / 2; i++)
{
if (Num % i == 0)
{
return 0;
}
}
return 1;
}
}
}