(3^n+1)/2 is prime iff n = 2^k for some k.
Theorem I
a^n + b^n = (a+b)(a^(n-1) - a^(n-2)b + . . . +b^(n-1)) for odd values of n.
Proof:
If n = 0, then (3^0+1)/2 = 2/2 = 1 not prime. So n > 0.
If n is odd then by Theorem I, 3^n+1 is div by (3+1)=4. Then (3^n+1)/2 = 2m, which
not prime. So n is not odd.
If n is even then n is a power of 2 or n = 2k(2m+1) for some k>0. We require k>0
since k=0 would imply n=0 which we have already shown is not possible.
Assume n = 2k(2m+1) for some k and m. By Theorem I, since 2m+1 is odd,
(3^2k)^(2m+1) + 1 is divisible by (3^2k+1). Now, since k>0, (3^2k+1)/2 > 1.
Then the minimum value of k=1 => 10/2 = 5 > 1. Thus, n is not of the form 2k(2x+1).
This implies n must be of the form 2^k as was desired.