Kotlin Program:

- To print half reverse triangle pattern using *

Example:

User Input: 4

Output:

* * * *
* * *
* *
*
fun main(args: Array<String>) {
  print("Enter two numbers : ") 
  val userInput = readLine()!!
  var rows:Int =userInput.toInt()
  for(i in rows downTo 1) {
    for(j in 1..i) {
      print("* ")
    }
    println("")
  }
}

Output:

  Enter number of rows : 4
  * * * *
  * * *
  * *
  *
Program
pattern

Main logic :

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

You can print any thing in this pattern, just replace your value with *

Concept

Coming Soon !

Quick
Tutorial

Quote

We are all now connected by the Internet, like neurons in a giant brain.