Problem 2: Basic While Loop
Points: 1
Submitting an external tool
A single positive variable number has been given as an input. Add commands to use a while loop to repeatedly divide this number by 7 until the value remaining is less than 1. Your code should assign values to two output variables as follows:
- Assign the final value of the number to the output variable "whatsLeft".
- Count the number of divisions required and assign the result to the output variable "divisionCount".
Script:
number = 256;
function [whatsLeft, divisionCount] = divideBySeven(number)
Save
My Solutions >
Reset
MATLAB Documentation