Kotlin Program:

- To print half triangle pattern using number

Example:

User Input: 3

Output:

1
1 2
1 2 3
fun main(args: Array<String>) {
  print("Enter number of rows : ") 
  val userInput = readLine()!!
  var rows:Int =userInput.toInt()

  for(i in 1..rows) {
    for(j in 1..i) {
      print(j +" ")
    }
    println("")
  }
}

Output:

  Enter number of rows : 4
  1
  1 2
  1 2 3
  1 2 3 4
Program
pattern

Main logic :

for(i in 1..rows) {  //rows : number of rows to print
  for(j in 1..i) {
    print(j +" ")
  }
  println("")
}
Concept

Coming Soon !

Quick
Tutorial

Quote

In order to carry a positive action, we must develop here a positive vision.