Skip to content

Instantly share code, notes, and snippets.

@Benjiko99
Last active September 17, 2018 11:10
Show Gist options
  • Save Benjiko99/a2056e0a73e82047ed0d1b5b056a78e5 to your computer and use it in GitHub Desktop.
Save Benjiko99/a2056e0a73e82047ed0d1b5b056a78e5 to your computer and use it in GitHub Desktop.
import java.util.Scanner
fun staircase(n: Int): Unit {
for (y in 1..n) {
var line = ""
for (x in 1..n) {
if (x <= n-y)
line += " "
else
line += "#"
}
System.out.println(line)
}
}
fun main(args: Array<String>) {
val scan = Scanner(System.`in`)
val n = scan.nextLine().trim().toInt()
staircase(n)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment