21. Let the set $S=\{1,2,3, \cdots, 50\}$, find the smallest positive integer $n$, such that every subset of $S$ containing $n$ elements has three numbers that can serve as the lengths of the three sides of a right triangle.
(1993 Chinese National Training Team Problem)
21. Let the three sides of a right-angled triangle be $x, y, z$, then the positive integers satisfying $x^{2}+y^{2}=z^{2}$ can be expressed as $x=k\left(a^{2}-b^{2}\right)$, $y=2 k a b, z=k\left(a^{2}+b^{2}\right)$, where $k, a, b \in \mathbf{N}_{+}$ and $(a, b)=1, a>b$. Then, one of $x, y, z$ must be a multiple of 5; otherwise, by the fact that 5 is a prime and Fermat's Little Theorem, and $51 x^{4}-1,5\left|y^{4}-1,5\right| z^{4}-1$, it follows that $51 z^{4}-x^{4}$. Since $z^{4}-x^{4}=\left(z^{2}+x^{2}\right) y^{2}$ and $5 \nmid y^{2}$, it follows that $5 \mid z^{2}+x^{2}$. Similarly, $5 \mid z^{2}+y^{2}$, hence $5 \mid z^{2}+x^{2}+z^{2}+y^{2}=3 z^{2}$, which is a contradiction. Let $A=\{S$ of numbers coprime with 5 $\}$, then $|A|=40$. Furthermore, with $10,15,25,40,45$ as one side and numbers in $A$ forming the following right-angled triangles: $(10,8,6),(26,24,10)$, $(15,12,9),(17,15,8),(36,39,15),(25,24,7),(40,32,24),(41,40,9),(45,27,36)$, there are no numbers in $A$ that can form a right-angled triangle with $10,15,25,40,45$. Let $M=A \cup\{10,15,25,40,45\} \backslash\{8,9,24,36\}$, then $|M|=41$, and no three numbers in $M$ can form the sides of a right-angled triangle, thus $n \geqslant 42$. On the other hand, consider the set $B=\{3,4,5,17,15,8, 29,21,20,25,24,7,34,16,30,37,35,12,50,48,14,41,40,9,45,36,27\},|B|=27,|S \backslash B|=50-27=23$. Taking any 42 numbers from $S$, there must be $42-23=19$ numbers in $B$, and since $B$ consists of 9 Pythagorean triplets, among these 19 numbers, at least $\left[\frac{19-1}{9}\right]+1=3$ belong to the same Pythagorean triplet, forming the sides of a right-angled triangle, so $n \leqslant 42$, hence the smallest positive integer $n$ is 42.