I need help to do the following loops and flow control

4 views (last 30 days)
Make function called loopTest(N) that loops through the values 1 through N and for each number n it should display ‘n is divisible by 2’, n is divisible by 3’, n is divisible by 2 and 3’ or ‘n is not divisible by 2 or 3’. Use a for loop, the function mod or rem to figure out if a number is divisible by 2 or 3, and num2str to convert each number to a string for displaying. You can use any combination of if, else and elseif.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!