# Why all composite numbers have this property?

Define $f(n)=\sum\limits_{A \in S} f_{1}(n,A),\ n>2,\ n \in \mathbb{Z}$, where $S$ is the power set of $\{\frac{1}{2},\cdots ,\frac{1}{n-1}\}$.

Define $\ f_1(n,\varnothing)=1,\ f_{1}(n,A)=(-1)^{\#A-2n\Sigma(A)}$, where $\#A$ is the size of the set $A$ and $\Sigma(A)$ is the sum of the elements of A.

Let's take $n = 5$, for example: \begin{align*} S = \{\\ & \varnothing,\\ & \{\frac{1}{2}\},\ \{\frac{1}{3}\},\ \{\frac{1}{4}\},\\ & \{\frac{1}{2},\frac{1}{3}\},\ \{\frac{1}{2},\frac{1}{4}\},\ \{\frac{1}{3},\frac{1}{4}\},\\ & \{\frac{1}{2},\frac{1}{3},\frac{1}{4}\}\\ \} \end{align*} $f(5)=1+(-1)^{1-2 \cdot 5 \cdot (\frac{1}{2})}+ \cdots +(-1)^{2-2 \cdot 5 \cdot (\frac{1}{2}+\frac{1}{3})} + \cdots + (-1)^{3-2 \cdot 5 \cdot (\frac{1}{2}+\frac{1}{3}+\frac{1}{4})}=4.7320508075688767+1.2679491924311326i$

My question is: Why for every composite number $n$ is the real part of $f(n)$ approximately $0$, while prime numbers do not have this property? Examples: \begin{align*} f(4) & = 1.887379141862766e-15-1.1102230246251565e-15i\\ f(22) & = -8.325340417059124e-12-7.568612403474617e-1i \end{align*}

P.S. Python code for $f(n),f_{1}(n,A)$:

import itertools

def f_1(n,A):
return (-1) ** (len(A) - 2 * n * (sum(A)))
def f(n):
l = [itertools.combinations([1/x for x in range(2,n)], x) for x in range(1,n-1)]
return round(sum([f_1(n,y) for x in l for y in x]).real) + 1

print(f(4))

# Output: 0

-
Any revise or edit of the definition for $f(n),f_{1}(n,A)$ are welcomed. – miket Jun 21 '14 at 1:52
I've updated the definition of $S$. My definition and the result become much nicer if you include the empty set, defining $f_1(n, \emptyset) = 1$. – RghtHndSd Jun 21 '14 at 2:01
@rghthndsd ,great thanks for the edit! – miket Jun 21 '14 at 2:01
@rghthndsd ,thanks for your advice,I updated the question. – miket Jun 21 '14 at 2:35

Because $f_1(n,A) = (-1)^{\#A-2n\sum A} = \prod_{x\in A} (-1)^{1-2nx}$, the sum over the power set of any set $B$ factors: $$\sum_{A\subset B} f_1(n,A) = \prod_{x\in B} \big( 1 + (-1)^{1-2nx} \big).$$ In particular, $$f(n) = \prod_{k=2}^{n-1} \big( 1 + (-1)^{1-2n/k} \big).$$ If $n$ is composite, then there exists an integer $2\le k\le n-1$ such that $k$ divides $n$; for such a $k$, we have $1 + (-1)^{1-2n/k} = 1+(-1)^{\text{some odd integer}}=0$. Therefore $f(n)$ is exactly equal to $0$ when $n$ is composite.