Exercise

For loops

In the next exercise we are going to write a for-loop. In that for-loop we are going to call a function. We define that function here.

Instructions

100 XP
  • Write a function compute_s_n that for any given \(n\) computes the sum \(S_n = 1^2 + 2^2 + 3^2 + \dots + n^2\).
  • Report the value of the sum when n=10.