Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
Create printPattern1.scala (#5645)
Browse files Browse the repository at this point in the history
Co-authored-by: Yuri Cunha <isyuricunha@duck.com>
  • Loading branch information
charan-hash and isyuricunha authored Apr 15, 2024
1 parent dad50e1 commit 4fae5ee
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions program/program/print-pattern-1/printPattern1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
object NumberPattern {
def main(args: Array[String]): Unit = {
// Taking input from the user
println("Enter the number of rows:")
val numRows = scala.io.StdIn.readInt()

// Printing the pattern
for (row <- 1 to numRows) {
// For each row, print numbers from 1 to row
for (num <- 1 to row) {
print(s"$num ")
}
println() // Move to the next line after printing each row
}
}
}

0 comments on commit 4fae5ee

Please sign in to comment.