注意运用 同于数定理:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Project_Euler_12
{
class Program
{
static void Main(string[] args)
{
int factors = 0;
int n = 1;
int trannum = 0;
do
{
trannum = (1 + n) * n / 2;
factors = 0;
for (int i = 1; i <= Math.Sqrt(trannum); i++)
{
if (trannum % i == 0)
{
factors +=2;
// Console.WriteLine(i);
}
}
n++;
} while (factors < 500);
Console.WriteLine(trannum);
Console.ReadLine();
}
}
}