prime number and order problem Does anyone can solve problem stated at
Is $n = k \cdot p^2 + 1$ necessarily prime if $2^k \not\equiv 1 \pmod{n}$ and $2^{n-1} \equiv 1 \pmod{n}$?
?
It should have the additional constraint, k < p.

Let $o$ be the order of $n$ to base $2$.
In other words, $o$ is the smallest positive natural number with $2^o\equiv 1\ \ (\ mod\ n\ )$
Because of $2^{n-1}\equiv 1\ (\ mod\ n\ )$, $o$ must be a divisor of
$n-1=kp^2$.
$o$ cannot be a divisor of $k$, because then we would have $2^k\equiv 1\ (\ mod\ n\ )$
So, $o$ must be a multiple of $p$. So, if $n$ is not prime, it must have
the form $(ap+1)(bp+1)=abp^2+(a+b)p+1=kp^2+1$ , with $a,b>0$ 
It follows $abp+a+b=kp$
Because of $k<p$, we have $ab<p$. Furthermore, we have $a+b\equiv 0\ (\ mod\ p\ )$.If we assume $a<b$, the only way to fulfill these equations is $a=1,b=p-1$.
So, $n=(p+1)((p-1)p+1)=p^3+1$
Which contradicts $n=kp^2+1$ with $k<p$.
So, $n$ must indeed be prime.
