I'm new here and I have an assignment about java that i'm not understand on how to do it.Here is the question:
Write a test program that read an integer n and call a method to display a pattern as follows:
1
2 1
3 2 1
4 3 2 1
...
n n-1 ... 3 2 1
The method header is
public static void displayPattern(int n)

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

Post what you have done so far and someone will help you from there.

Look at what is to be printed on each line. The first line has one number, the second line has two number. Each line starts with its line number and decrements. Make some loops that follows those rules.

try with this code it gives the above pattern (in java)

public void displayPattern(int n){
        for (int i = 1; i <= n; i++)
        {
            for (int j = i; j > 0; j--) {
                System.out.print("\t"+j);
            }
            System.out.println("");
        }
}

all the best,
radha krishna .peram

make loops as per your requirement...just think a little bit..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.