Skip to content

Instantly share code, notes, and snippets.

@thmain
Created June 6, 2018 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thmain/dcefeb08adc0ac017efdb54e7a009065 to your computer and use it in GitHub Desktop.
Save thmain/dcefeb08adc0ac017efdb54e7a009065 to your computer and use it in GitHub Desktop.
public class FloydTriangle {
public static void printTriangle(int rows){
if(rows<=0)
return;
int count=1;
int number = 1;
while(count<=rows){
for (int i = 0; i <count ; i++) {
System.out.print(number + " ");
number++;
}
count++;
System.out.println();
}
}
public static void main(String[] args) {
int rows = 7;
printTriangle(rows);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment