0

C# Code Project 33: Solved the challenge but not using recursion

static int Points(int levels) { var points = 0; for(int i = 1; i < levels + 1; i++) points += i; return points; } The instructions specify to "recursively calculate" but why when the above is simpler?

20th Oct 2021, 9:56 PM
Mark
2 Respostas
+ 1
Sololearn only checks whether your code produces the expected output for the given input. It does not check how that output is achieved. Because of that sololearn accepts solutions that don't follow the instructions as long as they produce the expected output.
20th Oct 2021, 10:15 PM
Simon Sauter
Simon Sauter - avatar
+ 1
The challenge specifically instructed us to do this using recursion because the goal of the challenge task is to encourage us to practice on the subject (recursion), in a hope that we understand it afterwards.
21st Oct 2021, 6:41 AM
Ipang