How many distinct terms are in the sequence generated by a^b for integers a and b, where 2 ≤ a ≤ 100, and 2 ≤ b ≤ 100? Can you find the answer without computing the value of each a^b? (Project Euler problem #29)
p=string.empty;
for a=sym(2):100
for b=2:100
v=a^b;
p(end+1)=string(v);
end
end
p=unique(p);
length(p)
finds 9183 distinct values.
Answer to the second question:
No, I couldn't do it without actual calculation.
|
Posted by Charlie
on 2024-02-20 11:55:58 |