MATLAB: Remainder while dividing a number by x number of digits

rem

if i have a line of code like this
while(rem(i,2) ~= 0 || rem(i,3) ~= 0 || rem(i,4) ~= 0
its OK if I know the limit of 'i' , what can I do to make i open ended such that I can input 'i' as any number and the while loop will be performed . E.G i = 30 , the the while loop continues up to 'rem(1,4)~=0'

Best Answer

Avoid using i as a variable name, it's meaningless and it's also a function in matlab.
To answer your question, use vectorised operations with any:
numdigits = 30; %your limit
value = 150; %your i
%test value against all numbers between 1 all at once (use array 1:numdigits)
%if ANY of the remainder is not 0, do something
while any(rem(value, 2:numdigits))
%do something
end