Question: Instructions If the language you are coding in uses 1 - based indexing Add the elements at the odd - numbered indexes to the total.

Instructions
If the language you are coding in uses 1-based indexing
Add the elements at the odd-numbered indexes to the total.
subtract the elements at the even-numbered indexes from the totat.
Note: Index 0 is considered an even index.
Then, based on the running totat, return a value according to the following rules:
If the total is divisible by 2(but not by 3), return the total multiplied by 2.
-If the total is divisible by 3(but not by 2), return the total muttiptied by 3.
If the total is divisible by 6, return the total multiplied by 6.
Otherwise, return the totai itself.
Write the function calculateRunningTotal that does this.
Example 1(assuming 0-based indexing):
Input:
n=3
my?list =123
Output:
.4
Explanation:
We add 1, subtract 2, and add 3 to get a total of 2. Since 2 is divisible by 2 but not by 3, we return 2 multiplied by 2, which is 4.
Example 2(assuming 0-based indexing):
Input:
n=3
my_list =803031
Instructions If the language you are coding in

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!