Write a program that reads a positive integer N and prints a triangle with N rows using asterisks ('*'). Each row should have one more asterisk than the previous row, starting with one asterisk in the first row.
Loops: repeat statement
Printing an ascending asterisk triangle
Report a typo
Sample Input 1:
5Sample Output 1:
*
**
***
****
*****Sample Input 2:
3Sample Output 2:
*
**
***Write a program in Kotlin
// Import for reading user input
import java.util.Scanner
fun main() {
val scanner = Scanner(System.`in`)
// Read the positive integer N
val n = scanner.nextInt()
// TODO: Print a triangle with N rows using asterisks ('*')
// - Each row should have one more asterisk than the previous row
// - Start with one asterisk in the first row
repeat(n) {
// Your code here
}
}
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.