Divisible by 3

I need to take an int variable that that will never be the same number, and check to see if it is divisible by 3. If it is not, I need to find the nearest number that is. Any suggestions?

if(integer % 3 != 0) //this is if the integer is not divisible by 3
{
integer += integer % 3; //this will add the remained of /3, therefor finding the next multiple
}

You could also use

newInt = oldInt / 3 * 3;

This solution will round towards zero.