1

I solve this problem for this way. but Errors continue to occur. I want to solve this errors. I want a way not to change much of the framework I used.

is_Prime_Number <- function(a)
x <- 1:100
if(x<=1){
 next
} else if(x==2){
 print(a)
} else if (x%%2==0){
 next
} else{
 y <-3
 is_prime <-1
 while(y <- as.integer(sqrt(x))){
  if(x%%y==0){
   is_prime <-0
   break
  }y<-y+2
 }if(is_prime ==1){
   print(a)
  }else{
   next
   }
}
result <- is_Prime_Number(a)
print(result)
d.b
  • 32,245
  • 6
  • 36
  • 77
daye
  • 19
  • 1
  • Can you explain **in the question** 1) what is `a`? 2) what is `x <- 1:100`? 3) why `y <- 3` and two instructions later you alter this value without ever using it? Also, `}y<-y+2` in the same code line is wrong, put the `y` instruction in the next line. – Rui Barradas Oct 05 '19 at 18:24
  • Related: https://stackoverflow.com/a/19767707/6574038 – jay.sf Oct 05 '19 at 22:20

0 Answers0