Build a while loop from scratch
The previous exercises guided you through developing a pretty advanced while loop, containing a break statement and different messages and updates as determined by control flow constructs. If you manage to solve this comprehensive exercise using a while loop, you're totally ready for the next topic: the for loop.
Bu egzersiz
Intermediate R
kursunun bir parçasıdırEgzersiz talimatları
Finish the while loop so that it:
- prints out the triple of
i, so3 * i, at each run. - is abandoned with a
breakif the triple ofiis divisible by 8.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
# Initialize i as 1
i <- 1
# Code the while loop
while (i <= 10) {
print(___)
if ((___) %% 8 == 0) {
___
}
i <- i + 1
}