0
$\begingroup$

Prove that the function $F(j) = \left\lfloor\cos\left(\pi\dfrac{(j-1)!+1}{j}\right)\right\rfloor$ returns $-1$ when $j$ is prime and $0$ when $j$ is composite.

First note that $$\cos(n\pi) =\left\{\begin{aligned}-1&, \quad \text{if} \text{ } n \text{ } \text{is odd}\\ 1&, \quad\text{if} \text{ } n \text{ } \text{is even}.\end{aligned}\right.$$ We have $F(2) = -1$. Now if $j > 2$ is prime, then by Wilson's Theorem $(j-1)!+1 \equiv 0 \pmod{j}$. Thus, since $j$ is odd and $(j-1)!+1$ is also odd, it follows that $\dfrac{(j-1)!+1}{j}$ is an odd integer and so $F(j) = -1$.

How do I solve it when $j$ is composite?

  • 0
    Hint: For $j>4$ not prime, $\frac{(j-1)!}{j}$ is an integer.2017-01-30
  • 0
    @ThomasAndrews Is $\frac{(j-1)!}{j}$ also even for $j > 4$ composite?2017-01-30
  • 0
    Yes, though you'd have to prove that. But basically, if $n=2k$ then $(2k-1)!$ is divisible by $2\cdot 4\cdot k$, at least when $k>4$. Then you have to deal with the cases $n=6,8$. When $n$ is odd, it is obviously true.2017-01-30
  • 0
    When $n$ is even, $\cos(n\pi) = 1$, not $0$. But you need to consider non-integer values as well.2017-01-30
  • 0
    @ThomasAndrews Ah, but I was merely addressing a prior edit where the formula in "First note that" contained that inaccuracy.2017-01-30

0 Answers 0