[R] Beginner problem - using mod function to print odd numbers

nelpar |e@ve@o|nyc @end|ng |rom gm@||@com
Wed Jun 2 20:17:50 CEST 2021


I don't understand. -- 

7%%2=1
9%%2=1
11%%2=1

What aren't these numbers printing ? 


num<-0
for (i in 1:100){
  num<-num+i
if (num%%2 != 0) 
  print(num)
}


[1] 1
[1] 3
[1] 15
[1] 21
[1] 45
[1] 55
[1] 91
[1] 105
[1] 153
[1] 171
[1] 231
[1] 253
[1] 325
[1] 351
[1] 435
[1] 465
[1] 561
[1] 595
[1] 703
[1] 741
[1] 861
[1] 903
[1] 1035
[1] 1081
[1] 1225
[1] 1275
[1] 1431
[1] 1485
[1] 1653
[1] 1711
[1] 1891
[1] 1953
[1] 2145
[1] 2211
[1] 2415
[1] 2485
[1] 2701
[1] 2775
[1] 3003
[1] 3081
[1] 3321
[1] 3403
[1] 3655
[1] 3741
[1] 4005
[1] 4095
[1] 4371
[1] 4465
[1] 4753
[1] 4851



--
Sent from: https://r.789695.n4.nabble.com/R-help-f789696.html



More information about the R-help mailing list