How to find out if a number is odd or even
Show older comments
n = input("ENTER A POSITIVE NUMBER "); if (modulo(n,2)==0) then disp("ENTER NUMBER IS EVEN"); else disp("ENTER NUMBER IS ODD"); end
Answers (1)
Walter Roberson
on 25 Mar 2022
0 votes
modulo is called mod() in MATLAB
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!