How to check divisibility?

359 views (last 30 days)
Caped Crusader
Caped Crusader on 20 Jan 2013
Answered: Jitesh Kumar on 25 Sep 2018
Hi, I need to check whether two numbers are divisible or not. But how can I do that in Matlab? e.g. Matlab gives 1.5 for 3/2 but I need to get 3/2 = 0 and 4/2 =2.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 20 Jan 2013
Edited: Azzi Abdelmalek on 20 Jan 2013
a=3;
b=2;
out=~rem(a,b)*a/b
  4 Comments
Caped Crusader
Caped Crusader on 20 Jan 2013
Thanks ,it works!
Caped Crusader
Caped Crusader on 20 Jan 2013
However, I used rem(a,b) format after checking the help files and it worked. Anyway thank you very much.

Sign in to comment.

More Answers (1)

Jitesh Kumar
Jitesh Kumar on 25 Sep 2018
a=5; b=1; rem(a,b)=4

Categories

Find more on Resizing and Reshaping Matrices 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!