Lua循环嵌套
#Lua 循环嵌套
Lua 编程语言允许使用循环嵌套。接下来这一节中将用例子来说嵌套循环的使用方法:
##语法
for 循环嵌套的语法如下:
1 | for init,max/min value, increment |
while(condition)
do
while(condition)
do
statement(s)
end
statement(s)
end
1 |
|
repeat
statement(s)
repeat
statement(s)
until( condition )
until( condition )
1 |
|
j =2
for i=2,10 do
for j=2,(i/j) , 2 do
if(not(i%j))
then
break
end
if(j > (i/j))then
print(“Value of i is”,i)
end
end
end
1 |
|
Value of i is 8
Value of i is 9
Value of i is 10