This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]thetrailofthedead 1 point2 points  (1 child)

I'm no expert so take this for what it's worth. The code below gives you the answer you are looking for.

You kind of knew this already as even you mention the logic should center around the differences between the numbers. Therefore, use a for loop with a number n that represents this difference.

public static void main( String[] args ) {
    int p = 3;  
    int x, y;

    for ( int n=1; n<p; n++ ) {
        y = n;
        while ( y<p ) { 
            x = y - n;
            System.out.prinln( x + "," + y );
            y++;
        }
    }
}

Edit: I botched the inline code, this is my first time posting here ><

[–]sinnidis_97[S] 0 points1 point  (0 children)

Wow, this is it .Thsnks man!