题目如下:
Consider all integer combinations of ab for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5:
=4,
=8,
=16,
=32
=9,
=27,
=81,
=243
=16,
=64,
=256,
=1024
=25,
=125,
=625,
=3125
If they are then placed in numerical order, with any repeats removed, we get the following sequence of 15 distinct terms:
4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125
How many distinct terms are in the sequence generated by ab for 2 ≤ a ≤ 100 and 2 ≤ b ≤ 100?
该题目直接计算不可取,需要把因子保留下来,对比因子即可
f = "";
for a = 2 : 100
for b = 2 : 100
c = sprintf("%d",repelem(factor(a),b));
if ~ismember(c,f)
f = [f,c];
end
end
end
length(f)-1;