I am trying to write a function to calculate all prime numbers below 100. Unfortunately, I need to use the mod division function in R (%%) to test each number from 1 to 100 against all values below it and the final output should result in a vector of all prime numbers.
Here is what I have so far, but am not sure where I'm going wrong, or how to go about fixing this at all. I'm new to programming and R, and so I'm having a bit of a tough time with it. I have looked at the other questions on StackOverflow to try to understand how to change the code to get it to work, but am not having any luck (also, when I try to run those codes, they do not seem to generate responses through R).
prime <- function(x){
for(i in 1:100)
if(x==1){print("TRUE")}
if((x %% (1:x-1))==0){print("TRUE")}
else{print("FALSE")}
print(seq(as.numeric("TRUE")))
Any help will be appreciated!
Thank you!