Menu
CoddyTech

Recap - Sigma Function

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

challenge icon

Challenge

Easy

Write a function named sigma with one int parameter n. It returns the sum of all the whole numbers from 1 to n, both included.

For example, sigma(5) returns 15, because 1 + 2 + 3 + 4 + 5 = 15.

The tests call sigma() themselves and check the value it returns. Do not call it, and do not print anything. The file needs only the function: no extends Node and no _ready().

Try it yourself

func sigma(n: int):
	# Write code here
	pass

All lessons in Fundamentals

Practice on your own: Online GDScript compiler