please tell me what's wrong in my program
:confused:
ok, i have recently learnt that 1729 is the only number that is the sum of two pairs of perfect cubes
viz: 1^3 + 12^3 = 10^3 + 9^3 = 1729..
But, i wasn't satisfied with this so I made a program to check.. Initially, i kept the ranges to be 1 to 100 , then changed it to 15 thinking whether 'int' would be enough for big numbers like 100^3... No matter what, it is supposed to show me 1729 (as 12<15)
But, it doesn't!! :mad:
Please tell me what mistake have I made... Because this program is not giving me any outputs..
//Why is this program not working???
public class Cubes
{
public static void main()
{
int[] a = new int[225];
int t;
for(int i=1; i<=15; i++)
{
for(int j=i; j<=15; j++)
{
t=i*i*i + j*j*j;
for(int l=0;l<225; l++)
{
if(a[l]==t)
{
System.out.println(a[l]);
}
}
for(int m=0; m<225; m++)
{
a[m] = t;
}
}
}
}
}
Please help me with this..:-??
Re: please tell me what's wrong in my program
Quote:
this program is not giving me any outputs..
Add some more calls to the println method to be sure the program shows what it is doing and has done.
The Arrays class's toString() method is helpful for showing what's in an array:
Code :
System.out.println("an ID "+ java.util.Arrays.toString(theArrayName));
Please edit your post and wrap your code with
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.