Kotlin Program:

- To print alphabet A pattern using *

Example:

User Input: 3

Output:

    *
  * * *
*       *
fun main(args: Array<String>) {
  print("Enter number of rows : ") 
  val userInput = readLine()!!
  var rows:Int =userInput.toInt()
  for(i in rows downTo 1) {
    for(j in 1..(2*rows-i)) {
      if(j==i||j==(2*rows-i)||(j>i && i==rows/2+rows%2)){
        print("* ")
      }
      else {
        print("  ")
      }
    }
    println("")
  }
}

Output:

Enter number of rows: 5

        *
      *   *
    * * * * *
  *           *
*               *
Program
pattern

Main Logic :

for(i in rows downTo 1) {  //rows : number of rows to print
  for(j in 1..(2*rows-i)) {
    if(j==i||j==(2*rows-i)||(j>i && i==rows/2+rows%2)){
      print("* ")
    }
    else {
      print("  ")
    }
  }
  println("")
}

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

Concept

Coming Soon !

Quick
Tutorial

Quote

Sometimes it’s the smallest decisions that can change your life forever.