How can I make a for loop a while loop?
1 次查看(过去 30 天)
显示 更早的评论
x57a= [];
for i= 1:1000
if rem(i,5) ==0 || rem(i,7) ==0
if rem(i,5)==0 && rem(i,7) ==0
continue;
end
x57a = [x57a, i];
end
end
I wrote this code as a for loop but I want to know how it would look like as a while loop
0 个评论
采纳的回答
Bhaskar R
2020-2-5
x57a= [];
i = 1;
while i<= 1000
if rem(i,5) ==0 || rem(i,7) ==0
if rem(i,5)==0 && rem(i,7) ==0
i = i +1;
continue;
end
x57a = [x57a, i];
end
i = i+1;
end
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!