Primes of the form $2n+1$ Let $\sigma(n)$ denotes the divisor function which sums the divisors of $n$, an integer $ \geq 1$.
We introduce the function $f$ such that:
$$f(n) = 1+(n!)^2-\sigma(n!)(n!)^2+2\sum_{k=1}^{-1+\sigma(n!)}\left \lfloor \frac{k(1+(n!)^2)}{\sigma(n!)} \right\rfloor$$
When $f(n)=2n+1$, is $2n+1$ always prime?
I failed to compute big numbers because of factorials.
The first examples are:
$
1, 1, 1, 1, 1, 13, 1, 17, 1, 1, 1, 1, 1, 1,
 1, 1, 1, 1, 1, 1, 61, 1, 1, 1, 1, 1, 1, 1, 1, 61,
1, 1, 1, 193, 1, 1, 1, 757, 61, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 109, 1, 1, 1, 181, 1, 1,
 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 1, 1, 1, 1, 1, 1, 1, 1, 113...$
And for example for $n=6$ we have the prime number $13$ that is of the form $2(6)+1$.
Thanks.
 A: Let $\{x\}=x-\lfloor x\rfloor$, let $m=n!$, and let $t=\sigma(m)$. Then
$$2\sum_{k=1}^{t-1}\left\lfloor\frac{k(1+m^2)}{t}\right\rfloor=\sum_{k=0}^{t-1}\frac{2k(1+m^2)}t-2\sum_{k=0}^{t-1}\left\{\frac{k(1+m^2)}t\right\};$$
the first sum is $(1+m^2)(t-1)$, and so
\begin{align*}
f(n)
&=1+m^2-m^2t+(1+m^2)(t-1)-2\sum_{k=0}^{t-1}\left\{\frac{k(1+m^2)}t\right\}\\
&=t-2\sum_{k=0}^{t-1}\left\{\frac{k(1+m^2)}t\right\}.
\end{align*}
Let $u=\gcd(1+m^2,t)$. The $t$ values $\{0,1+m^2,2(1+m^2),\dots,(t-1)(1+m^2)\}$  modulo $t$ consist of $u$ copies of each multiple of $u$ in $[0,t)$, and so
$$\sum_{k=0}^{t-1}\left\{\frac{k(1+m^2)}t\right\}=u\sum_{j=0}^{\frac tu-1}\frac{uj}t=\frac{t-u}2.$$
This means
$$f(n)=t-2\frac{t-u}2=\gcd(1+(n!)^2,\sigma(n!)).$$
(In particular, if $1+(n!)^2$ and $\sigma(n!)$ are coprime, $f(n)=1$.)
With this knowledge about $f(n)$, we can tackle the problem at hand. If $f(n)=2n+1$, then, in particular, $2n+1$ divides $1+(n!)^2$. So, $2n+1$ is relatively prime to $n!$. This means that $2n+1$ cannot have any factors in the set $\{2,\dots,n\}$. However, every number in $\{n+1,\dots,2n\}$ is too large to be a factor of $2n+1$. So, $2n+1$ cannot have any factors strictly between $1$ and $2n+1$, and must be prime.
