Something is illegal with that code?

Code:
for(i = 0; numero %  (teste.at(teste.capacity()-o)) == 0; i++, o++)
Im getting a runtime error "std:ut_of_range at memory location xxxxxx".
And if i put a "6" in the place of the "(teste.at(teste.capacity()-o))" the code runs.