Our FSE 100 teacher gave us this prompt:
"Show 'Mutually Prime' or 'Not Mutually Prime' if two numbers are inputted."
So I created this code, which seems to work perfectly fine:
a = input('Input first number: ');
b = input('Input second number: ');
limit = b
limit = a;
counter = 0;
for v = 2:limit
x = mod(a,v);
y = mod(b,v);
if (x == 0) && (y == 0)
counter = 1;
if (counter == 0 && a~=b)
disp('Not Mutually Prime');
And most of the time, I'm getting outputs I want, like this one below:
BUT sometimes I'm getting an output that looks like this:
This type of output occassionally shows up, and other times it doesn't, so I'm a little confused, especially since I'm new to MATLAB coding. Is this something MATLAB does, fluctuating the outputs like this? Or is there something wrong in my own code?
Basically, does anyone know if I can fix this so that, somehow, the "limit = ..." portion never shows up in the ouput?
ALSO another problem I'm having is when the two numbers inputted by the user are the same:
It's correct that they aren't mutually prime, but It's printing "100" twice, which I don't want. I can't seem to spot where the problem could be.