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 based indexing
Add the elements at the oddnumbered indexes to the total.
subtract the elements at the evennumbered indexes from the totat.
Note: Index 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 but not by return the total multiplied by
If the total is divisible by but not by return the total muttiptied by
If the total is divisible by return the total multiplied by
Otherwise, return the totai itself.
Write the function calculateRunningTotal that does this.
Example assuming based indexing:
Input:
list
Output:
Explanation:
We add subtract and add to get a total of Since is divisible by but not by we return multiplied by which is
Example assuming based indexing:
Input:
mylist
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
