问题:求这种四个自然数p,q,r,s(p<=q<=r<=s)。使得等式1/p + 1/q +1/r +1/s=1成立。
分析:将原式同分,化简整理后得到:2<=p<5,p<=q<7,q
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int p, q, r, s, n = 0;
for (p = 2; p <5; p++)
for (q = p; q <7; q++)
for (r = q; r <13; r++)
if (p * q * r - q * r - p * r - p * q != 0)
{
s = (p * q * r) / (p * q * r - q * r - p * r - p * q);
if ((p * q * r)%(p * q * r - q * r - p * r - p * q)==0 && s >= r)
Console.WriteLine("[{0}]:1/{1}+1/{2}+1/{3}+1/{4}=1" + ‘\n‘,string.Format("{0,2}",++n),p,q,r,s);
}
}
}
}