Triangular
Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
The triangular numbers count the number of objects in arrangements that look like triangles. The first few are 1, 3, 6, and 10 as shown below.

Below, we give you a C implementation of an algorithm that computes the nth triangular number given n.
int n; //contains starting value (assume has valid value)
int running_sum = 0;
for (int i = 1; i <= n; i++) {
running_sum += i;
}
Your task is to translate this algorithm into assembly. Assume that the value of n is stored in register a0 when your code begins execution. You may use registers a0-a7 in your solution. Your final answer (corresponding to the final value of running_sum) should be in register a7 when your code stops executing.
This problem has (and all RISCV coding questions have) a built-in debugger you're free to use. Details are here.