The documentation for seq notes that the length.out value will be rounded. Since a is numeric and therefore associated with some error, it is possible to get another length than you expect, which gives you a weird result.
for (a in seq(0, 4, length.out=41)[1:7]){ print(paste(as.integer(10*a+1), ceiling(10*a+1))) } # [1] "1 1" # [1] "2 2" # [1] "3 3" # [1] "4 4" # [1] "5 5" # [1] "6 6" # [1] "7 8"
Pay attention to the last line: you get 8 instead of 7.
To solve this problem, try converting the length to an integer by rounding:
for (b in seq(0, a, length.out=round(10*a+1))){
source share