Aha! Very interesting results. I have taught number theory but never studied the primes in depth.
​
Your series is quite different than Fermat’s. His grows much faster:
In[]:=
d=1;​​ListPlot[Table[(
n
2
-1)-(
8
n
-d+
4
n
),{n,2,50}]]
Out[]=
10
20
30
40
50
-6×
12
10
-4×
12
10
-2×
12
10
2×
12
10
... and in further comparison, I wonder if this ever occurs:
​
(n∈) ∧ (n>1) ∧ (m∈) ∧ (m>1) ∧ (d ∈ {1,3,7,9}) :
n
2
-1

8
m
+
4
m
-d
??
​
I was also curious about your function f[n]. It contains the 2 lines
In[]:=
y=x;​​a=((x+y/2+x-y-1)/(x-y-1))-((x+y))/(x+y)/2;
which simplify to
a=
1
2
(1-3x);
Is there a reason to keep the formula containing y?