Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

If this can be done ASAP that would be nice. I will post more of this question f

ID: 656576 • Letter: I

Question

If this can be done ASAP that would be nice. I will post more of this question for who ever answers this for more points. thanks

For integer numbers between 1 and 30, check for and report numbers that are:

- divisible by 3, but not divisible by 2
- divisible by both 2 and 3.

It does not need to report other cases (such as numbers that are divisible by only 2).

When run, your program should display lines similar to these:
"3 is divisible by 3, but not divisible by 2"
"6 is divisible by both 2 and 3"
"9 is divisible by 3, but not divisible by 2"

Take the following hints into consideration in writing your program:
*   Use a for loop that will run from n = 1 to 30
*   In the loop, for each n value,
-calculate the remainder after division by 2 by -using the rem function
-calculate the remainder after division by 3 by using the rem function
-create a string variable strn by converting the number n to a string using num2str
function (this will be useful in displaying the required lines)
-Use an if-end structure with proper relational and conditional operators (and the
calculated remainder values) to properly implement the conditional cases
mentioned above.
-Use the disp command to display the required lines on the command window.

Explanation / Answer

for i= 1 : 30
rem2 = rem(number,2);
rem3 = rem(number,3);
if rem2==0 && rem3==0
result = 'Your n is divisible by both 2 and 3';

elseif rem3==0
result = 'Your n is divisible by 3, but not by 2';
else
result = 'Your n is not divisible by 2 or 3';
end
disp(n,result)
end