logo CodeStepByStep logo

floydsTriangle

Language/Type: Java for

Write a method named floydsTriangle that accepts an integer k as a parameter and prints a k-row version of Floyd's triangle. Floyd's triangle is a sequence of increasing numbers, starting with 1, where each Nth row of numbers displays the next N numbers in the sequence. For example, the call of floydsTriangle(5); should print the following console output:

1
2 3
4 5 6
7 8 9 10
11 12 13 14 15

If k is 0 or negative, print no output.

Method: Write a Java method as described, not a complete program or class.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.