如果一个正整数n满足n=a^3+b^3(其中a,b为正整数且0<a<=b)则称n为双倍立方数。求从1到10000的超立方数
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace chaolifang
{
class Program
{
public void Fun(int n)
{
for (int i = 1; i < n; i++)
{
for (int j = 1; j <= i; j++)
{
if (n == (i * i * i + j * j * j))
{
Console.WriteLine("{0}={1}^3+{2}^3", n, i, j);
}
else
break;
}
}
}
static void Main(string[] args)
{
Program p = new Program();
for (int i = 1; i <= 10000; i++)
{
p.Fun(i);
}
Console.ReadKey();
}
}
}
运行结果:
2=1^3+1^3
9=2^3+1^3
28=3^3+1^3
65=4^3+1^3
126=5^3+1^3
217=6^3+1^3
344=7^3+1^3
513=8^3+1^3
730=9^3+1^3
1001=10^3+1^3
1332=11^3+1^3
1729=12^3+1^3
2198=13^3+1^3
2745=14^3+1^3
3376=15^3+1^3
4097=16^3+1^3
4914=17^3+1^3
5833=18^3+1^3
6860=19^3+1^3
8001=20^3+1^3
9262=21^3+1^3