Flat Asterisk Pyramid
Part of the Fundamentals section of Coddy's GDScript journey. Lesson 90 of 92.
Challenge
MediumThe 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
4Operators Part 1
Arithmetic OperatorsInteger DivisionModulo OperatorArithmetic ShortcutsRecap - Simple MathComparison Operators10Functions
Declare a FunctionArgumentsReturnReturn TypesRecap - Sigma FunctionRecap - Validation FunctionDefault Values5Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 3Ternary OperatorPractice on your own: Online GDScript compiler