Hello everyone,

I am having trouble with my code to list all the prime numbers in R. This is what I have thus far:

```
prime = 0:100
for(val in prime){
if (val == 0){
next
} else if (val == 1){
next
} else if(val == 2){
val = 2
} else if (val %% 2 == 0){
next
} else if (val == 3){
val = 3
} else if (val %% 3 == 0){
next
} else if (val == 5){
val = 5
} else if (val %% 5 == 0){
next
}
print(val)
}
```

The problem is that I can't keep listing all the prime numbers because there are infiniately many, and the perfect squares for a prime number keep coming up. I was wondering if anyone can help me out with this. I am super new to R and we just started using while loops and if/else statements, so please don't use something too fancy. Thank you for the help in advance.