Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Star Triangle

Use a for loop to print a right triangle made of * characters. Each line should have one more star than the last.

Expected output:

text
*
**
***
****
*****

Hints:

  • Use for i in 1..=5 to loop 5 times
  • The .repeat() method can repeat a string: "*".repeat(3) gives ***
  • Print "*".repeat(i) on each line — but i needs to be the right type!
  • Use "*".repeat(i as usize) if needed to convert the number type
rust
fn main() {
}