📘 Lesson  ·  Lesson 60

Floyds Triangle

Floyds Triangle

Print Floyd's Triangle in Java

Floyd's triangle prints consecutive numbers in a right-angled triangle shape.

Java Program

int num = 1, rows = 4;
for (int i = 1; i <= rows; i++) {
    for (int j = 1; j <= i; j++) {
        System.out.print(num + " ");
        num++;
    }
    System.out.println();
}

Output

1 2 3 4 5 6 7 8 9 10

How it Works

  • A counter increases continuously across all rows.
  • Row i prints i numbers.

Summary

  • Floyd's triangle prints consecutive numbers in a right-angled triangle shape.

Print Floyd's Triangle in Java

Floyd's triangle consecutive numbers को right-angled triangle आकार में print करता है।

Java Program

int num = 1, rows = 4;
for (int i = 1; i <= rows; i++) {
    for (int j = 1; j <= i; j++) {
        System.out.print(num + " ");
        num++;
    }
    System.out.println();
}

Output

1 2 3 4 5 6 7 8 9 10

कैसे काम करता है

  • एक counter सभी rows में लगातार बढ़ता है।
  • Row i में i numbers print होते हैं।

सारांश

  • Floyd's triangle consecutive numbers को right-angled triangle आकार में print करता है।
← Back to Java Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

\n