Sure! By Wilson's theorem, [math]n + 1[/math] is a prime if and only if [math]n! \mod (n + 1) = n[/math]. That means that if we define
[math]\displaystyle f(n) = \left\lfloor \frac{n! \mod (n + 1)}{n}\right\rfloor (n - 1) + 2, \tag*{}[/math]
then [math]f(n) = n + 1[/math] if [math]n + 1[/math] is prime, and [math]f(n) = 2[/math] otherwise. In other words, this function will always output pri...
Không có nhận xét nào:
Đăng nhận xét