Print stars like a Triangle in Ruby

Ruby code to print stars like a Triangle

Source code :

SYMBOL = "*" #Change the Symbol
    
def triangle(i, t=0)
    if i == 0
        return 0
    else
        puts ' ' * ( i + 1 ) + SYMBOL * ( t * 2 + 1 )
        return triangle( i - 1, t + 1 )
    end

end
    
triangle(5)

Output :

      *
     *
    ***
   *
  ***

Output :


                

Comments :