//What is the largest prime factor of the number 600851475143 ?
static void Main(string[] args)
{
//int[] number = new int[100];
long[] number = new long[1228]; //通过count计数得到容器一共收录1228个long型数据
ArrayList list = new ArrayList();
//int count = 0;
for (int i = 3; i < 10000; i++)
{
int index = -1;
for (int j = 2; j < i; j++)
{
if (i % j != 0 && i != j)
{
}
else
{
index += 1;
}
}
if (index == -1)
{
list.Add(i);
//Console.WriteLine(i);
//count += 1;
}
}
long num = 0;
for (int i = 0; i < 1228; i++)
{
string str = list[i].ToString();
num = long.Parse(str);
//Console.WriteLine(num);
number[i] = num;
}
//Console.WriteLine(count); //以上均为计算10000以内的所有的所有质数代码
//int max = 13195;
long max = 600851475143;
for (int i = 0; i < 1228; i++)
{
if (max % number[i] == 0)
{
Console.WriteLine(number[i]);
max = max / number[i]; //如果该值除以某质数余数为0,则进行除法运算更换该值
}
}
}