Pascal, 1 token
Pascal does not have bitwise operators.
(Some dialects do and some implementations use under the hood bitwise operators for operations on the set
data type nevertheless.)
Since the in
set membership operator is not listed among the allowed operators, another relational operator is used:
type
wholeNumberLessThan256 = 0..255;
function divisibleByThree(n: wholeNumberLessThan256): Boolean;
const
wholeNumbersLessThan256divisibleByThree = [
0, 3, 6, 9, 12, 15, 18, 21, 24, 27,
30, 33, 36, 39, 42, 45, 48, 51, 54, 57,
60, 63, 66, 69, 72, 75, 78, 81, 84, 87,
90, 93, 96, 99, 102, 105, 108, 111, 114, 117,
120, 123, 126, 129, 132, 135, 138, 141, 144, 147,
150, 153, 156, 159, 162, 165, 168, 171, 174, 177,
180, 183, 186, 189, 192, 195, 198, 201, 204, 207,
210, 213, 216, 219, 222, 225, 228, 231, 234, 237,
240, 243, 246, 249, 252, 255];
begin
{ In Pascal `<=` denotes the `⊆` operator with sets. }
divisibleByThree := [n] <= wholeNumbersLessThan256divisibleByThree;
end;
Extended Pascal, 0 token
NB:
A lookup table could be written in Standard Pascal (ISO standard 7185), too.
type
wholeNumberLessThan256 = 0‥255;
{ The reserved word `protected` is defined by Extended Pascal.
It just means the value of `n` may not be altered in the definition. }
function divisibleByThree(protected n: wholeNumberLessThan256): Boolean;
type
tableFormat = array[type of n] of Boolean;
const
lookupTable = tableFormat[
0, 3, 6, 9, 12, 15, 18, 21, 24, 27,
30, 33, 36, 39, 42, 45, 48, 51, 54, 57,
60, 63, 66, 69, 72, 75, 78, 81, 84, 87,
90, 93, 96, 99, 102, 105, 108, 111, 114, 117,
120, 123, 126, 129, 132, 135, 138, 141, 144, 147,
150, 153, 156, 159, 162, 165, 168, 171, 174, 177,
180, 183, 186, 189, 192, 195, 198, 201, 204, 207,
210, 213, 216, 219, 222, 225, 228, 231, 234, 237,
240, 243, 246, 249, 252, 255: true;
otherwise false
];
begin
divisibleByThree ≔ lookupTable[n];
end;