In MATLAB find the smallest number of unique multiplesof3 th
In MATLAB, find the smallest number of unique multiples-of-3 that, when multiplied together, produce a result that exceeds 500,000. Notice that 3 × 6 < 500,000, so 2 is not the desired number. Similarly, 3 × 6 × 9 < 500,000, so 3 is not the desired number. Et cetera.
Use a while-loop. Display both the number of terms involved and their product (which should be larger than 500,000).
Solution
Here is the code for you:
count = 1;
result = 3;
while(result <= 500000)
count = count + 1;
result = result * count * 3;
end
fprintf(\'The number of terms involved in their product is: %d\ \', count);
fprintf(\'And the terms are: \');
for i = 1 : count
fprintf(\'%d \', i * 3);
end
fprintf(\'\ \');

