Final answer:
To solve this problem, you can use a while loop in the function.
First, initialize the 'whatsLeft' variable with the input 'number'.
Then, use a while loop to continuously divide 'whatsLeft' by 7 until it becomes less than 1.
Keep track of the number of divisions using the 'divisionCount' variable.
Step-by-step explanation:
The steps are given below:
- First, initialize the 'whatsLeft' variable with the input 'number'.
- Then, use a while loop to continuously divide 'whatsLeft' by 7 until it becomes less than 1.
- Keep track of the number of divisions using the 'divisionCount' variable.
- Finally, assign the final value of 'whatsLeft' to the 'whatsLeft' output variable, and assign the value of 'divisionCount' to the 'divisionCount' output variable.
Here's an example of how the code should look:
function [whatsLeft, divisionCount] = divideBySeven(number)
whatsLeft = number;
divisionCount = 0;
while whatsLeft >= 1
whatsLeft = whatsLeft / 7;
divisionCount = divisionCount + 1;
end
end