Why is this while loop not working? Prime number from list
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Catalytic Kys
le 2 Déc 2019
Commenté : Catalytic Kys
le 2 Déc 2019
clear;
close all
clc;
N = 10;
list=2:N;
values = [2];
list(find(mod(list,2)==0))=[];
tester = 3;
while list ~= []
list(find(mod(list,tester)==0))=[];
tester = list(1);
values = values + [, tester];
end
0 commentaires
Réponse acceptée
JESUS DAVID ARIZA ROYETH
le 2 Déc 2019
because what you want to write in matlab would be like this:
while ~isempty(list)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements 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!