Inside the code editor we've tried to write a function that takes a number n as argument and returns the sum of all numbers 0 through n (0 + 1 + 2 + ... + n - 1).
So when we called computeSum(4), we expected our code to print:
6
because 0 + 1 + 2 + 3 = 6. But it seems like we made some mistakes because when we run our code, it prints:
16
Assignment:
Your task is to fix our function such that it correctly computes and returns the desired sum.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check