Why is this while loop not working? Prime number from list
1 view (last 30 days)
Show older comments
Catalytic Kys
on 2 Dec 2019
Commented: Catalytic Kys
on 2 Dec 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 Comments
Accepted Answer
JESUS DAVID ARIZA ROYETH
on 2 Dec 2019
because what you want to write in matlab would be like this:
while ~isempty(list)
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements 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!