Skip to content

Instantly share code, notes, and snippets.

@0x73hahd
Created January 24, 2023 04:30
Show Gist options
  • Save 0x73hahd/d1af2601524b0ab0f38a2eceb036926b to your computer and use it in GitHub Desktop.
Save 0x73hahd/d1af2601524b0ab0f38a2eceb036926b to your computer and use it in GitHub Desktop.
Inverted half pyramid of numbers in rust
use std::io;
fn main(){
let mut rows = String::new();
io::stdin()
.read_line(&mut rows)
.expect("failed to readline");
let row = rows.trim().parse::<i64>().unwrap();
for n in (0..row+1).rev() {
for mut y in (1..n+1) {
print!("{y}");
}
print!("\n");
}
}
@0x73hahd
Copy link
Author

An example of the output:

12345
1234
123
12
1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment