Effacer les filtres
Effacer les filtres

I am trying to store the (non-repetitive) numbers in B = [3,5] after factorizing 225 = 3 x 3 x 5 x 5, but executing the code it stores only one, i.e. B = [3].

1 vue (au cours des 30 derniers jours)
%
A = factor(225);
B(1) = A(1);
flag = 0;
for i = 1:length(A)-1;
for j = i + 1;
if A(i) == A(j)
flag = flag + 1;
break
end
end
if flag == 0;
B(count) = A(i);
count = count + 1;
end
end

Réponse acceptée

Stephen23
Stephen23 le 11 Avr 2016
>> unique(factor(225))
ans =
3 5

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by