matlab.sample 542 Bytes
Newer Older
Sergey's avatar
Sergey committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22


clear
number = input('Give an integer: ');
remainder2 = rem(number,2);
remainder3 = rem(number,3);

if remainder2==0 & remainder3==0
    'Your number is divisible by both 2 and 3'
else
    if remainder2==0
        'Your number is divisble by 2 but not by 3'
    else
        if remainder3==0
            'Your number is divisible by 3 but not by 2'
        else
            'Your number is not divisible by either 2 or 3'
        end
    end
end

% From https://www.math.colostate.edu/~yzhou/course/matlab_doc/matlab_programming_intro.html