Menu
CoddyTech

Flat Asterisk Pyramid

Part of the Fundamentals section of Coddy's GDScript journey. Lesson 90 of 92.

challenge icon

Challenge

Medium

The program reads one line of input: an odd whole number n (always odd, from 1 to 999).

Print a pyramid of * characters whose bottom row has n stars. The first row has 1 star, and each row has two stars more than the row above it.

For 1, the output is:

*

For 5, the output is:

*
***
*****

For 7, the output is:

*
***
*****
*******

Start from the small pyramids, and open the hints if you are stuck.

Try it yourself

extends Node

func _ready():
	var n := int(OS.read_string_from_stdin())

	# Print the pyramid here
	pass

All lessons in Fundamentals

Practice on your own: Online GDScript compiler