There is no formula for this problem (that I know of).
I had to reason it out . . .
A set with only a finite number of integers as members,
has the property that the average of any 3 of its members is not an integer.
What is the maximum number of elements that may have?
There are three types of integers:
. . (1) A multiple of 3: .
. . (2) One more than a multiple of 3: .
. . (3) One less than a multiple of 3: .
We must not have 3 of type (1), or 3 of type (2), or 3 of type (3).
. . Their averages would be integers.
We can have at most two of one type.
We must not have one of each type.
. . Their average would be an integer.
We can have at most two types of numbers.
Hence, we can have (at most) two each of two types of numbers.
Therefore, set can have a maximum of 4 elements.