Ashley P.
asked 11/08/19Java Number Patterns
How do we print,
_ _ _ _1
_ _ _2 1
_ _3 2 1
_ 4 3 2 1
In Java?
Please help, I don't know how to get started
2 Answers By Expert Tutors

Patrick B. answered 11/08/19
Math and computer tutor/teacher
class PrintPattern
{
public static void main(String args[])
{
int numStart=0;
for (int iLoop=4; iLoop>0; iLoop--)
{
numStart++;
for (int jLoop=0; jLoop<iLoop; jLoop++)
{
System.out.print("_");
if (jLoop<iLoop-1) { System.out.print(" "); } // if you don't want the space between each underscore, then comment out this line
}
for (int jLoop=numStart; jLoop>0; jLoop--)
{
System.out.print(jLoop);
}
System.out.println(" ");
}
}
}
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.