Attempting to use bitwise operations, not working how I'd expect it to

I’m trying to use bitwise operations to figure out if a given value exists within a set of values. For example, I have the numbers 2, 5, and 7. Those are team numbers, and I would like my code to return true if the player’s team matches one of those values. Here is some code:

[lua]
function( ply )
local validTeams = bit.bor(2, 5, 7)
local binCheck = bit.band( validTeams, ply:Team() )
print("Is valid? "…tostring(binCheck == ply:Team()))
end
[/lua]

Which will print out true if my team number is one (not good). I was following a guide from the old wiki, but I don’t think the underlying concept of bitwise operations have changed much… Can anyone point out what I’m doing wrong here?

That snippet will only work with powers of two.

Ahh… Besides using powers of two, am I out of luck?

Well if you wanna use bitwise stuff, then powers of two is the only way.

Alright, lesson learned. Thanks, guys