「Swift入門」whileとrepeat-whileの使い方

1.while文

var n = 0
 
while n <= 16 {
    n = n + 1
 
    if n % 3 == 0 {
        continue
    }
 
    print(n)
}

2.repeat-while文

var m = 0
 
repeat {
    m = m + 1
 
    if m % 3 == 0 {
        continue
    }
 
    print(m)
} while m <= 16

 

Swift

Posted by arkgame