matlab code to find out how many unique terms are in the sequence generated by a^b for 2<=a<=100 and 2<=b=100

1 view (last 30 days)
how?

Answers (1)

Image Analyst
Image Analyst on 18 May 2014
I hope this isn't your homework (you did not tag it as such). Here is my answer:
a = 2:100
b = 2 : 100
[A, B] = meshgrid(a,b)
z = A .^ B;
fprintf('Total number of elements = %d\n', numel(z));
fprintf('Total number of unique elements = %d\n', length(unique(z)));

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!