Kotlin Program:

- To print half triangle pattern using number

Example:

User Input: 3

Output:

1
2 2
3 3 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(i+" ")
    }
    println("")
  }
}

Output:

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

Main logic :

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

Coming Soon !

Quick
Tutorial

Quote

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