{
  "index": "2015-A-5",
  "type": "NT",
  "tag": [
    "NT",
    "COMB",
    "ALG"
  ],
  "difficulty": "",
  "question": "Let $q$ be an odd positive integer, and let $N_q$ denote the number of integers $a$ such that $0 < a < q/4$ and $\\gcd(a,q) = 1$. Show that $N_q$ is odd if and only if $q$ is of the form $p^k$ with $k$ a positive integer and $p$ a prime congruent to $5$ or $7$ modulo $8$.",
  "solution": "\\textbf{First solution:}\nBy inclusion-exclusion, we have\n\\begin{align*}\nN_q    &= \\sum_{d|q} \\mu(d) \\left\\lfloor \\frac{\\lfloor q/4\\rfloor}{d} \\right\\rfloor \\\\\n       &= \\sum_{d|q} \\mu(d) \\left\\lfloor \\frac{q/d}{4} \\right\\rfloor \\\\\n  &\\equiv \\sum_{d|q \\mbox{\\, \\small squarefree}} \\left\\lfloor \\frac{q/d}{4}  \\right\\rfloor  \\pmod{2},\n\\end{align*}\nwhere $\\mu$ is the M\\\"obius function.\nNow\n\\[\n\\left\\lfloor \\frac{q/d}{4} \\right\\rfloor \\equiv \\begin{cases} 0 \\pmod{2} & \\mbox{if } q/d\\equiv 1, 3 \\pmod{8} \\\\\n1 \\pmod{2} & \\mbox{if } q/d\\equiv 5, 7 \\pmod{8}.\n\\end{cases}\n\\]\nSo $N_q$ is odd if and only if $q$ has an odd number of squarefree factors $q/d$ congruent to $5$ or $7$ (mod~8).\n\nIf $q$ has a prime factor $p$ congruent to 1 or 3 (mod~8), then the squarefree factors $d$ of $q$ occur in pairs $c,pc$, which are either both 1 or 3 (mod~8) or both 5 or 7 (mod~8).  Hence $q$ must have an even number of factors that are congruent to $5$ or $7$ (mod~8), and so $N_q$ is even in this case.\n\nIf $q$ has two prime factors $p_1$ and $p_2$, each congruent to either 5 or 7 (mod~8), then the squarefree factors $d$ of $q$ occur in quadruples $d,p_1d,q_1d,p_1q_1d$, which are then congruent respectively to some permutation of 1,3,5,7 (mod~8) (if $p_1$ and $p_2$ are distinct mod 8) or are congruent respectively to $d,p_1d,p_1d,d$ (mod~8). Either way, we see that exactly two of the four residues are congruent to $5$ or $7$ (mod~8).  Thus again $q$ must have an even number of factors that are $5$ or $7$ (mod~8), and so $N_q$ is even in this case as well.\n\nIf $q=1$, then $N_q=0$ is even.  The only case that remains is that $q=p^k$ is a positive power of a prime $p$ congruent to 5 or 7 (mod~8).  In this case, $q$ has two squarefree factors, $1$ and $p$, of which exactly one is congruent to $5$ or $7$ (mod~8).  We conclude that $N_q$ is odd in this case, as desired.\n\n\\noindent\n\\textbf{Second solution:}\n\nConsider the set $S$ of all integers in $\\{1,\\ldots,q-1\\}$ that are even and relatively prime to $q$.  Then the product of all elements in $S$ is\n\\[\n2^{\\phi(q)/2}\\prod_{{1\\leq a\\leq (q-1)/2}\\atop{(a,q)=1}} a.\n\\]\nOn the other hand, we can rewrite the set of elements in $S \\pmod{q}$ as a set $T$ of residues in the interval $[-(q-1)/2,(q-1)/2]$.  Then for each $1\\leq a\\leq (q-1)/2$ with $(a,q)=1$, $T$ contains exactly one element from $\\{a,-a\\}$: if $-2r \\equiv 2s \\pmod{q}$ for some $r,s\\in\\{1,\\ldots,(q-1)/2\\}$, then $r \\equiv -s \\pmod{q}$, which is impossible given the ranges of $r$ and $s$.  Thus the product of all elements in $T$ is\n\\[\n(-1)^n \\prod_{{1\\leq a\\leq (q-1)/2}\\atop{(a,q)=1}} a,\n\\]\nwhere $n$ denotes the number of elements of $S$ greater than $(q-1)/2$.\nWe conclude that $(-1)^n \\equiv 2^{\\phi(q)/2} \\pmod{q}$.\n\nHowever, note that the number of elements of $S$ less than $(q-1)/2$ is equal to $N_q$, since dividing these numbers by 2 gives exactly the numbers counted by $N_q$. Hence the total cardinality of $S$ is $N_q + n$; however, this cardinality also equals $\\phi(q)/2$ because the numbers in $\\{1,\\dots,q-1\\}$ relatively prime to $q$ come in pairs\n$\\{a,q-a\\}$ in each of which exactly one member is even. We thus obtain\n\\begin{align*}\n(-1)^{N_q} &= (-1)^{\\phi(q)/2 + n} \\\\\n&\\equiv (-1)^{\\phi(q)/2} 2^{\\phi(q)/2} = (-2)^{\\phi(q)/2} \\pmod{q}.\n\\end{align*}\nIf $q=1$, then $N_q$ is even.  If $q$ has more than one prime factor, then the group $(\\mathbb{Z}/q\\mathbb{Z})^\\times$ has exponent dividing $\\phi(q)/2$, so $(-1)^{N_q}\\equiv (-2)^{\\phi(q)/2} \\equiv 1 \\pmod{q}$, and thus $N_q$ must be even in this case as well.  Finally, suppose that $q$ is a prime power $p^k$ with $p$ odd and $k$ positive.  Since $(\\mathbb{Z}/q\\mathbb{Z})^\\times$ is a cyclic group of order $\\phi(q)=p^{k-1}(p-1)$, in which the only square roots of unity are $\\pm 1$, it follows that $(-2)^{\\phi(q)/2}\\equiv \\pm 1 \\pmod{q}$ in accordance with whether $(-2)^{(p-1)/2} \\equiv \\pm 1 \\pmod{p}$, i.e., whether $-2$ is a quadratic residue or nonresidue.  But recall that $-2$ is a quadratic residue modulo $p$ if and only if $p\\equiv 1, 3 \\pmod{8}$. Thus $N_q$ is odd in this case if and only if $p\\equiv 5$ or $7 \\pmod{8}$.\n\nWe conclude that for any odd integer $q\\geq 1$, the quantity $N_q$ is odd if and only if $q=p^k$ with $k$ positive and $p$ a prime that is 5 or 7 (mod~8).\n\n\\noindent\n\\textbf{Remark:} The combination of the two solutions recovers Gauss's criterion for when $-2$ is a quadratic residue modulo $p$, with essentially the original proof.",
  "vars": [
    "a",
    "d",
    "c",
    "S",
    "T",
    "n",
    "r",
    "s",
    "N_q"
  ],
  "params": [
    "q",
    "p",
    "k",
    "p_1",
    "p_2",
    "q_1",
    "\\\\mu"
  ],
  "sci_consts": [],
  "variants": {
    "descriptive_long": {
      "map": {
        "a": "smallint",
        "d": "divisor",
        "c": "cofactor",
        "S": "seteven",
        "T": "setresi",
        "n": "countbig",
        "r": "firstidx",
        "s": "secondx",
        "N_q": "countrel",
        "q": "modulus",
        "p": "primevar",
        "k": "powexpo",
        "p_1": "primeone",
        "p_2": "primetwo",
        "q_1": "primealt",
        "\\\\mu": "mobiusf"
      },
      "question": "Let $modulus$ be an odd positive integer, and let $countrel$ denote the number of integers $smallint$ such that $0 < smallint < modulus/4$ and $\\gcd(smallint,modulus) = 1$. Show that $countrel$ is odd if and only if $modulus$ is of the form $primevar^{powexpo}$ with $powexpo$ a positive integer and $primevar$ a prime congruent to $5$ or $7$ modulo $8$.",
      "solution": "\\textbf{First solution:}\\nBy inclusion-exclusion, we have\\n\\begin{align*}\\ncountrel    &= \\sum_{divisor|modulus} mobiusf(divisor) \\left\\lfloor \\frac{\\lfloor modulus/4\\rfloor}{divisor} \\right\\rfloor \\\\       &= \\sum_{divisor|modulus} mobiusf(divisor) \\left\\lfloor \\frac{modulus/divisor}{4} \\right\\rfloor \\\\  &\\equiv \\sum_{divisor|modulus \\mbox{\\, \\small squarefree}} \\left\\lfloor \\frac{modulus/divisor}{4}  \\right\\rfloor  \\pmod{2},\\n\\end{align*}\\nwhere $mobiusf$ is the M\"obius function.\\nNow\\n\\[\\n\\left\\lfloor \\frac{modulus/divisor}{4} \\right\\rfloor \\equiv \\begin{cases} 0 \\pmod{2} & \\mbox{if } modulus/divisor\\equiv 1, 3 \\pmod{8} \\\\1 \\pmod{2} & \\mbox{if } modulus/divisor\\equiv 5, 7 \\pmod{8}.\\end{cases}\\n\\]\\nSo $countrel$ is odd if and only if $modulus$ has an odd number of squarefree factors $modulus/divisor$ congruent to $5$ or $7$ (mod~8).\\n\\nIf $modulus$ has a prime factor $primevar$ congruent to 1 or 3 (mod~8), then the squarefree factors $divisor$ of $modulus$ occur in pairs $cofactor,primevar cofactor$, which are either both 1 or 3 (mod~8) or both 5 or 7 (mod~8).  Hence $modulus$ must have an even number of factors that are congruent to $5$ or $7$ (mod~8), and so $countrel$ is even in this case.\\n\\nIf $modulus$ has two prime factors $primeone$ and $primetwo$, each congruent to either 5 or 7 (mod~8), then the squarefree factors $divisor$ of $modulus$ occur in quadruples $divisor,primeone divisor,primealt divisor,primeone primealt divisor$, which are then congruent respectively to some permutation of 1,3,5,7 (mod~8) (if $primeone$ and $primetwo$ are distinct mod 8) or are congruent respectively to $divisor,primeone divisor,primeone divisor,divisor$ (mod~8). Either way, we see that exactly two of the four residues are congruent to $5$ or $7$ (mod~8).  Thus again $modulus$ must have an even number of factors that are $5$ or $7$ (mod~8), and so $countrel$ is even in this case as well.\\n\\nIf $modulus=1$, then $countrel=0$ is even.  The only case that remains is that $modulus=primevar^{powexpo}$ is a positive power of a prime $primevar$ congruent to 5 or 7 (mod~8).  In this case, $modulus$ has two squarefree factors, $1$ and $primevar$, of which exactly one is congruent to $5$ or $7$ (mod~8).  We conclude that $countrel$ is odd in this case, as desired.\\n\\n\\noindent\\n\\textbf{Second solution:}\\n\\nConsider the set $seteven$ of all integers in $\\{1,\\ldots,modulus-1\\}$ that are even and relatively prime to $modulus$.  Then the product of all elements in $seteven$ is\\n\\[2^{\\phi(modulus)/2}\\prod_{\\{1\\leq smallint\\leq (modulus-1)/2\\}\\atop{(smallint,modulus)=1}} smallint.\\]\\nOn the other hand, we can rewrite the set of elements in $seteven \\pmod{modulus}$ as a set $setresi$ of residues in the interval $[-(modulus-1)/2,(modulus-1)/2]$.  Then for each $1\\leq smallint\\leq (modulus-1)/2$ with $(smallint,modulus)=1$, $setresi$ contains exactly one element from $\\{smallint,-smallint\\}$: if $-2 firstidx \\equiv 2 secondx \\pmod{modulus}$ for some $firstidx,secondx\\in\\{1,\\ldots,(modulus-1)/2\\}$, then $firstidx \\equiv -secondx \\pmod{modulus}$, which is impossible given the ranges of $firstidx$ and $secondx$.  Thus the product of all elements in $setresi$ is\\n\\[(-1)^{countbig} \\prod_{\\{1\\leq smallint\\leq (modulus-1)/2\\}\\atop{(smallint,modulus)=1}} smallint,\\]\\nwhere $countbig$ denotes the number of elements of $seteven$ greater than $(modulus-1)/2$.\\nWe conclude that $(-1)^{countbig} \\equiv 2^{\\phi(modulus)/2} \\pmod{modulus}$.\\n\\nHowever, note that the number of elements of $seteven$ less than $(modulus-1)/2$ is equal to $countrel$, since dividing these numbers by 2 gives exactly the numbers counted by $countrel$. Hence the total cardinality of $seteven$ is $countrel + countbig$; however, this cardinality also equals $\\phi(modulus)/2$ because the numbers in $\\{1,\\dots,modulus-1\\}$ relatively prime to $modulus$ come in pairs $\\{smallint,modulus-smallint\\}$ in each of which exactly one member is even. We thus obtain\\n\\begin{align*}\\n(-1)^{countrel} &= (-1)^{\\phi(modulus)/2 + countbig} \\\\&\\equiv (-1)^{\\phi(modulus)/2} 2^{\\phi(modulus)/2} = (-2)^{\\phi(modulus)/2} \\pmod{modulus}.\\n\\end{align*}\\nIf $modulus=1$, then $countrel$ is even.  If $modulus$ has more than one prime factor, then the group $(\\mathbb{Z}/modulus\\mathbb{Z})^\\times$ has exponent dividing $\\phi(modulus)/2$, so $(-1)^{countrel}\\equiv (-2)^{\\phi(modulus)/2} \\equiv 1 \\pmod{modulus}$, and thus $countrel$ must be even in this case as well.  Finally, suppose that $modulus$ is a prime power $primevar^{powexpo}$ with $primevar$ odd and $powexpo$ positive.  Since $(\\mathbb{Z}/modulus\\mathbb{Z})^\\times$ is a cyclic group of order $\\phi(modulus)=primevar^{powexpo-1}(primevar-1)$, in which the only square roots of unity are $\\pm 1$, it follows that $(-2)^{\\phi(modulus)/2}\\equiv \\pm 1 \\pmod{modulus}$ in accordance with whether $(-2)^{(primevar-1)/2} \\equiv \\pm 1 \\pmod{primevar}$, i.e., whether $-2$ is a quadratic residue or nonresidue.  But recall that $-2$ is a quadratic residue modulo $primevar$ if and only if $primevar\\equiv 1, 3 \\pmod{8}$. Thus $countrel$ is odd in this case if and only if $primevar\\equiv 5$ or $7 \\pmod{8}$.\\n\\nWe conclude that for any odd integer $modulus\\geq 1$, the quantity $countrel$ is odd if and only if $modulus=primevar^{powexpo}$ with $powexpo$ positive and $primevar$ a prime that is 5 or 7 (mod~8).\\n\\n\\noindent\\textbf{Remark:} The combination of the two solutions recovers Gauss's criterion for when $-2$ is a quadratic residue modulo $primevar$, with essentially the original proof."
    },
    "descriptive_long_confusing": {
      "map": {
        "a": "lanterns",
        "d": "butterfly",
        "c": "toothpick",
        "S": "heliostat",
        "T": "windstorm",
        "n": "honeycomb",
        "r": "marigold",
        "s": "pineapple",
        "N_q": "juggernaut",
        "q": "poppyseed",
        "p": "blueberry",
        "k": "salamander",
        "p_1": "dragonfly",
        "p_2": "stonewall",
        "q_1": "bottleneck",
        "\\mu": "\\whirlwind"
      },
      "question": "Let $poppyseed$ be an odd positive integer, and let $juggernaut$ denote the number of integers $lanterns$ such that $0 < lanterns < poppyseed/4$ and $\\gcd(lanterns,poppyseed) = 1$. Show that $juggernaut$ is odd if and only if $poppyseed$ is of the form $blueberry^{salamander}$ with $salamander$ a positive integer and $blueberry$ a prime congruent to $5$ or $7$ modulo $8$.",
      "solution": "\\textbf{First solution:}\\nBy inclusion\\textendash exclusion, we have\\n\\n\\begin{align*}\\njuggernaut    &= \\sum_{butterfly|poppyseed} \\whirlwind(butterfly) \\left\\lfloor \\frac{\\lfloor poppyseed/4\\rfloor}{butterfly} \\right\\rfloor \\\\[-4pt]\\n       &= \\sum_{butterfly|poppyseed} \\whirlwind(butterfly) \\left\\lfloor \\frac{poppyseed/butterfly}{4} \\right\\rfloor \\\\[-4pt]\\n  &\\equiv \\sum_{butterfly|poppyseed \\mbox{\\, \\small squarefree}} \\left\\lfloor \\frac{poppyseed/butterfly}{4}  \\right\\rfloor  \\pmod{2},\\n\\end{align*}\\nwhere $\\whirlwind$ is the M\\\"obius function.\\n\\n\\[\\n\\left\\lfloor \\frac{poppyseed/butterfly}{4} \\right\\rfloor \\equiv \\begin{cases} 0 \\pmod{2} & \\mbox{if } poppyseed/butterfly\\equiv 1, 3 \\pmod{8} \\\\[-2pt]\\n1 \\pmod{2} & \\mbox{if } poppyseed/butterfly\\equiv 5, 7 \\pmod{8}.\\end{cases}\\n\\]\\nThus $juggernaut$ is odd if and only if $poppyseed$ has an odd number of squarefree factors $poppyseed/butterfly$ congruent to $5$ or $7$ (mod\\,$8$).\\n\\nIf $poppyseed$ has a prime factor $blueberry$ congruent to $1$ or $3$ (mod\\,$8$), then the squarefree factors $butterfly$ of $poppyseed$ occur in pairs $toothpick,\\,blueberry\\,toothpick$, which are either both $1$ or $3$ (mod\\,$8$) or both $5$ or $7$ (mod\\,$8$). Hence $poppyseed$ must have an even number of factors that are congruent to $5$ or $7$ (mod\\,$8$), and so $juggernaut$ is even in this case.\\n\\nIf $poppyseed$ has two prime factors $dragonfly$ and $bottleneck$, each congruent to either $5$ or $7$ (mod\\,$8$), then the squarefree factors $butterfly$ of $poppyseed$ occur in quadruples $butterfly,\\,dragonfly\\,butterfly,\\,bottleneck\\,butterfly,\\,dragonfly\\,bottleneck\\,butterfly$, which are then congruent respectively to some permutation of $1,3,5,7$ (mod\\,$8$) (if $dragonfly$ and $bottleneck$ are distinct mod\\,$8$) or are congruent respectively to $butterfly,\\,dragonfly\\,butterfly,\\,dragonfly\\,butterfly,\\,butterfly$ (mod\\,$8$). Either way, exactly two of the four residues are congruent to $5$ or $7$ (mod\\,$8$). Thus again $poppyseed$ must have an even number of factors that are $5$ or $7$ (mod\\,$8$), and so $juggernaut$ is even in this case as well.\\n\\nIf $poppyseed=1$, then $juggernaut=0$ is even. The only case that remains is that $poppyseed=blueberry^{salamander}$ is a positive power of a prime $blueberry$ congruent to $5$ or $7$ (mod\\,$8$). In this case, $poppyseed$ has two squarefree factors, $1$ and $blueberry$, of which exactly one is congruent to $5$ or $7$ (mod\\,$8$). We conclude that $juggernaut$ is odd in this case, as desired.\\n\\n\\noindent\\textbf{Second solution:}\\n\\nConsider the set $heliostat$ of all integers in $\\{1,\\ldots,poppyseed-1\\}$ that are even and relatively prime to $poppyseed$. Then the product of all elements in $heliostat$ is\\n\\[\\n2^{\\phi(poppyseed)/2}\\prod_{{1\\leq lanterns\\leq (poppyseed-1)/2}\\atop{(lanterns,poppyseed)=1}} lanterns.\\n\\]\\nOn the other hand, we can rewrite the set of elements in $heliostat \\pmod{poppyseed}$ as a set $windstorm$ of residues in the interval $[-(poppyseed-1)/2,(poppyseed-1)/2]$. Then for each $1\\leq lanterns\\leq (poppyseed-1)/2$ with $(lanterns,poppyseed)=1$, $windstorm$ contains exactly one element from $\\{lanterns,-lanterns\\}$: if $-2\\,marigold \\equiv 2\\,pineapple \\pmod{poppyseed}$ for some $marigold,\\,pineapple\\in\\{1,\\ldots,(poppyseed-1)/2\\}$, then $marigold \\equiv -pineapple \\pmod{poppyseed}$, which is impossible given the ranges of $marigold$ and $pineapple$. Thus the product of all elements in $windstorm$ is\\n\\[\\n(-1)^{honeycomb} \\prod_{{1\\leq lanterns\\leq (poppyseed-1)/2}\\atop{(lanterns,poppyseed)=1}} lanterns,\\n\\]\\nwhere $honeycomb$ denotes the number of elements of $heliostat$ greater than $(poppyseed-1)/2$.\\nWe conclude that $(-1)^{honeycomb} \\equiv 2^{\\phi(poppyseed)/2} \\pmod{poppyseed}$.\\n\\nHowever, the number of elements of $heliostat$ less than $(poppyseed-1)/2$ is equal to $juggernaut$, since dividing these numbers by $2$ gives exactly the numbers counted by $juggernaut$. Hence the total cardinality of $heliostat$ is $juggernaut + honeycomb$; but this cardinality also equals $\\phi(poppyseed)/2$ because the numbers in $\\{1,\\dots,poppyseed-1\\}$ relatively prime to $poppyseed$ come in pairs $\\{lanterns,\\,poppyseed-lanterns\\}$ in each of which exactly one member is even. We thus obtain\\n\\n\\begin{align*}\\n(-1)^{juggernaut} &= (-1)^{\\phi(poppyseed)/2 + honeycomb} \\\\[2pt]\\n&\\equiv (-1)^{\\phi(poppyseed)/2} 2^{\\phi(poppyseed)/2} = (-2)^{\\phi(poppyseed)/2} \\pmod{poppyseed}.\\n\\end{align*}\\n\\nIf $poppyseed=1$, then $juggernaut$ is even. If $poppyseed$ has more than one prime factor, then the group $(\\mathbb{Z}/poppyseed\\mathbb{Z})^\\times$ has exponent dividing $\\phi(poppyseed)/2$, so $(-1)^{juggernaut}\\equiv (-2)^{\\phi(poppyseed)/2} \\equiv 1 \\pmod{poppyseed}$, and thus $juggernaut$ must be even in this case as well.\\n\\nFinally, suppose that $poppyseed$ is a prime power $blueberry^{salamander}$ with $blueberry$ odd and $salamander$ positive. Since $(\\mathbb{Z}/poppyseed\\mathbb{Z})^\\times$ is a cyclic group of order $\\phi(poppyseed)=blueberry^{salamander-1}(blueberry-1)$, in which the only square roots of unity are $\\pm 1$, it follows that $(-2)^{\\phi(poppyseed)/2}\\equiv \\pm 1 \\pmod{poppyseed}$ in accordance with whether $(-2)^{(blueberry-1)/2} \\equiv \\pm 1 \\pmod{blueberry}$, i.e., whether $-2$ is a quadratic residue or nonresidue. But recall that $-2$ is a quadratic residue modulo $blueberry$ if and only if $blueberry\\equiv 1, 3 \\pmod{8}$. Thus $juggernaut$ is odd in this case if and only if $blueberry\\equiv 5$ or $7 \\pmod{8}$.\\n\\nWe conclude that for any odd integer $poppyseed\\geq 1$, the quantity $juggernaut$ is odd if and only if $poppyseed=blueberry^{salamander}$ with $salamander$ positive and $blueberry$ a prime that is $5$ or $7$ (mod\\,$8$).\\n\\n\\noindent\\textbf{Remark:} The combination of the two solutions recovers Gauss's criterion for when $-2$ is a quadratic residue modulo $blueberry$, with essentially the original proof."
    },
    "descriptive_long_misleading": {
      "map": {
        "a": "fractionalvalue",
        "d": "multiple",
        "c": "composite",
        "S": "oddnumbers",
        "T": "nonresidues",
        "n": "emptiness",
        "r": "endpoint",
        "s": "startpoint",
        "N_q": "lackcount",
        "q": "evenzero",
        "p": "nonprime",
        "k": "fraction",
        "p_1": "nonprimeone",
        "p_2": "nonprimetwo",
        "q_1": "evenzeroone",
        "\\\\mu": "eulerphi"
      },
      "question": "Let $evenzero$ be an odd positive integer, and let $lackcount$ denote the number of integers $fractionalvalue$ such that $0 < fractionalvalue < evenzero/4$ and $\\gcd(fractionalvalue,evenzero) = 1$. Show that $lackcount$ is odd if and only if $evenzero$ is of the form $nonprime^{fraction}$ with $fraction$ a positive integer and $nonprime$ a prime congruent to $5$ or $7$ modulo $8$.",
      "solution": "\\textbf{First solution:}\nBy inclusion-exclusion, we have\n\\begin{align*}\nlackcount    &= \\sum_{multiple|evenzero} eulerphi(multiple) \\left\\lfloor \\frac{\\lfloor evenzero/4\\rfloor}{multiple} \\right\\rfloor \\\\\n       &= \\sum_{multiple|evenzero} eulerphi(multiple) \\left\\lfloor \\frac{evenzero/multiple}{4} \\right\\rfloor \\\\\n  &\\equiv \\sum_{multiple|evenzero \\mbox{\\, \\small squarefree}} \\left\\lfloor \\frac{evenzero/multiple}{4}  \\right\\rfloor  \\pmod{2},\n\\end{align*}\nwhere $eulerphi$ is the M\"obius function.\nNow\n\\[\n\\left\\lfloor \\frac{evenzero/multiple}{4} \\right\\rfloor \\equiv \\begin{cases} 0 \\pmod{2} & \\mbox{if } evenzero/multiple\\equiv 1, 3 \\pmod{8} \\\\\n1 \\pmod{2} & \\mbox{if } evenzero/multiple\\equiv 5, 7 \\pmod{8}.\n\\end{cases}\n\\]\nSo $lackcount$ is odd if and only if $evenzero$ has an odd number of squarefree factors $evenzero/multiple$ congruent to $5$ or $7$ (mod~8).\n\nIf $evenzero$ has a prime factor $nonprime$ congruent to 1 or 3 (mod~8), then the squarefree factors $multiple$ of $evenzero$ occur in pairs $composite,nonprime composite$, which are either both 1 or 3 (mod~8) or both 5 or 7 (mod~8).  Hence $evenzero$ must have an even number of factors that are congruent to $5$ or $7$ (mod~8), and so $lackcount$ is even in this case.\n\nIf $evenzero$ has two prime factors $nonprimeone$ and $nonprimetwo$, each congruent to either 5 or 7 (mod~8), then the squarefree factors $multiple$ of $evenzero$ occur in quadruples $multiple,nonprimeone multiple,evenzeroone multiple,nonprimeone evenzeroone multiple$, which are then congruent respectively to some permutation of 1,3,5,7 (mod~8) (if $nonprimeone$ and $nonprimetwo$ are distinct mod 8) or are congruent respectively to $multiple,nonprimeone multiple,nonprimeone multiple,multiple$ (mod~8). Either way, we see that exactly two of the four residues are congruent to $5$ or $7$ (mod~8).  Thus again $evenzero$ must have an even number of factors that are $5$ or $7$ (mod~8), and so $lackcount$ is even in this case as well.\n\nIf $evenzero=1$, then $lackcount=0$ is even.  The only case that remains is that $evenzero=nonprime^{fraction}$ is a positive power of a prime $nonprime$ congruent to 5 or 7 (mod~8).  In this case, $evenzero$ has two squarefree factors, $1$ and $nonprime$, of which exactly one is congruent to $5$ or $7$ (mod~8).  We conclude that $lackcount$ is odd in this case, as desired.\n\n\\noindent\n\\textbf{Second solution:}\n\nConsider the set $oddnumbers$ of all integers in $\\{1,\\ldots,evenzero-1\\}$ that are even and relatively prime to $evenzero$.  Then the product of all elements in $oddnumbers$ is\n\\[\n2^{\\phi(evenzero)/2}\\prod_{{1\\leq fractionalvalue\\leq (evenzero-1)/2}\\atop{(fractionalvalue,evenzero)=1}} fractionalvalue.\n\\]\nOn the other hand, we can rewrite the set of elements in $oddnumbers \\pmod{evenzero}$ as a set $nonresidues$ of residues in the interval $[-(evenzero-1)/2,(evenzero-1)/2]$.  Then for each $1\\leq fractionalvalue\\leq (evenzero-1)/2$ with $(fractionalvalue,evenzero)=1$, $nonresidues$ contains exactly one element from $\\{fractionalvalue,-fractionalvalue\\}$: if $-2endpoint \\equiv 2startpoint \\pmod{evenzero}$ for some $endpoint,startpoint\\in\\{1,\\ldots,(evenzero-1)/2\\}$, then $endpoint \\equiv -startpoint \\pmod{evenzero}$, which is impossible given the ranges of $endpoint$ and $startpoint$.  Thus the product of all elements in $nonresidues$ is\n\\[\n(-1)^{emptiness} \\prod_{{1\\leq fractionalvalue\\leq (evenzero-1)/2}\\atop{(fractionalvalue,evenzero)=1}} fractionalvalue,\n\\]\nwhere $emptiness$ denotes the number of elements of $oddnumbers$ greater than $(evenzero-1)/2$.\nWe conclude that $(-1)^{emptiness} \\equiv 2^{\\phi(evenzero)/2} \\pmod{evenzero}$.\n\nHowever, note that the number of elements of $oddnumbers$ less than $(evenzero-1)/2$ is equal to $lackcount$, since dividing these numbers by 2 gives exactly the numbers counted by $lackcount$. Hence the total cardinality of $oddnumbers$ is $lackcount + emptiness$; however, this cardinality also equals $\\phi(evenzero)/2$ because the numbers in $\\{1,\\dots,evenzero-1\\}$ relatively prime to $evenzero$ come in pairs\n$\\{fractionalvalue,evenzero-fractionalvalue\\}$ in each of which exactly one member is even. We thus obtain\n\\begin{align*}\n(-1)^{lackcount} &= (-1)^{\\phi(evenzero)/2 + emptiness} \\\\\n&\\equiv (-1)^{\\phi(evenzero)/2} 2^{\\phi(evenzero)/2} = (-2)^{\\phi(evenzero)/2} \\pmod{evenzero}.\n\\end{align*}\nIf $evenzero=1$, then $lackcount$ is even.  If $evenzero$ has more than one prime factor, then the group $(\\mathbb{Z}/evenzero\\mathbb{Z})^\\times$ has exponent dividing $\\phi(evenzero)/2$, so $(-1)^{lackcount}\\equiv (-2)^{\\phi(evenzero)/2} \\equiv 1 \\pmod{evenzero}$, and thus $lackcount$ must be even in this case as well.  Finally, suppose that $evenzero$ is a prime power $nonprime^{fraction}$ with $nonprime$ odd and $fraction$ positive.  Since $(\\mathbb{Z}/evenzero\\mathbb{Z})^\\times$ is a cyclic group of order $\\phi(evenzero)=nonprime^{fraction-1}(nonprime-1)$, in which the only square roots of unity are $\\pm 1$, it follows that $(-2)^{\\phi(evenzero)/2}\\equiv \\pm 1 \\pmod{evenzero}$ in accordance with whether $(-2)^{(nonprime-1)/2} \\equiv \\pm 1 \\pmod{nonprime}$, i.e., whether $-2$ is a quadratic residue or nonresidue.  But recall that $-2$ is a quadratic residue modulo $nonprime$ if and only if $nonprime\\equiv 1, 3 \\pmod{8}$. Thus $lackcount$ is odd in this case if and only if $nonprime\\equiv 5$ or $7 \\pmod{8}$.\n\nWe conclude that for any odd integer $evenzero\\geq 1$, the quantity $lackcount$ is odd if and only if $evenzero=nonprime^{fraction}$ with $fraction$ positive and $nonprime$ a prime that is 5 or 7 (mod~8).\n\n\\noindent\n\\textbf{Remark:} The combination of the two solutions recovers Gauss's criterion for when $-2$ is a quadratic residue modulo $nonprime$, with essentially the original proof."
    },
    "garbled_string": {
      "map": {
        "a": "lqtnfsvr",
        "d": "jzkmtrpl",
        "c": "gbhxsdnw",
        "S": "kprlqvzt",
        "T": "mzxdfghu",
        "n": "vrhtclks",
        "r": "vxmntjqp",
        "s": "dqrlhzvn",
        "N_q": "zsdpnklt",
        "q": "htqwdbrm",
        "p": "bxvqcznt",
        "k": "hrlmcgsp",
        "p_1": "qlksvtxn",
        "p_2": "zrmtjphx",
        "q_1": "fnwdzsch",
        "\\mu": "fjrlgskp"
      },
      "question": "Let $htqwdbrm$ be an odd positive integer, and let $zsdpnklt$ denote the number of integers $lqtnfsvr$ such that $0 < lqtnfsvr < htqwdbrm/4$ and $\\gcd(lqtnfsvr,htqwdbrm) = 1$. Show that $zsdpnklt$ is odd if and only if $htqwdbrm$ is of the form $bxvqcznt^{hrlmcgsp}$ with $hrlmcgsp$ a positive integer and $bxvqcznt$ a prime congruent to $5$ or $7$ modulo $8$.",
      "solution": "\\textbf{First solution:}\nBy inclusion-exclusion, we have\n\\begin{align*}\nzsdpnklt    &= \\sum_{jzkmtrpl|htqwdbrm} fjrlgskp(jzkmtrpl) \\left\\lfloor \\frac{\\lfloor htqwdbrm/4\\rfloor}{jzkmtrpl} \\right\\rfloor \\\\\n       &= \\sum_{jzkmtrpl|htqwdbrm} fjrlgskp(jzkmtrpl) \\left\\lfloor \\frac{htqwdbrm/jzkmtrpl}{4} \\right\\rfloor \\\\\n  &\\equiv \\sum_{jzkmtrpl|htqwdbrm \\mbox{\\, \\small squarefree}} \\left\\lfloor \\frac{htqwdbrm/jzkmtrpl}{4}  \\right\\rfloor  \\pmod{2},\n\\end{align*}\nwhere $fjrlgskp$ is the M\"obius function.\nNow\n\\[\n\\left\\lfloor \\frac{htqwdbrm/jzkmtrpl}{4} \\right\\rfloor \\equiv \\begin{cases} 0 \\pmod{2} & \\mbox{if } htqwdbrm/jzkmtrpl\\equiv 1, 3 \\pmod{8} \\\\\n1 \\pmod{2} & \\mbox{if } htqwdbrm/jzkmtrpl\\equiv 5, 7 \\pmod{8}.\n\\end{cases}\n\\]\nSo $zsdpnklt$ is odd if and only if $htqwdbrm$ has an odd number of squarefree factors $htqwdbrm/jzkmtrpl$ congruent to $5$ or $7$ (mod~8).\n\nIf $htqwdbrm$ has a prime factor $bxvqcznt$ congruent to 1 or 3 (mod~8), then the squarefree factors $jzkmtrpl$ of $htqwdbrm$ occur in pairs $gbhxsdnw,bxvqcznt gbhxsdnw$, which are either both 1 or 3 (mod~8) or both 5 or 7 (mod~8).  Hence $htqwdbrm$ must have an even number of factors that are congruent to $5$ or $7$ (mod~8), and so $zsdpnklt$ is even in this case.\n\nIf $htqwdbrm$ has two prime factors $qlksvtxn$ and $zrmtjphx$, each congruent to either 5 or 7 (mod~8), then the squarefree factors $jzkmtrpl$ of $htqwdbrm$ occur in quadruples $jzkmtrpl,qlksvtxn jzkmtrpl,fnwdzsch jzkmtrpl,qlksvtxn fnwdzsch jzkmtrpl$, which are then congruent respectively to some permutation of 1,3,5,7 (mod~8) (if $qlksvtxn$ and $zrmtjphx$ are distinct mod 8) or are congruent respectively to $jzkmtrpl,qlksvtxn jzkmtrpl,qlksvtxn jzkmtrpl,jzkmtrpl$ (mod~8). Either way, we see that exactly two of the four residues are congruent to $5$ or $7$ (mod~8).  Thus again $htqwdbrm$ must have an even number of factors that are $5$ or $7$ (mod~8), and so $zsdpnklt$ is even in this case as well.\n\nIf $htqwdbrm=1$, then $zsdpnklt=0$ is even.  The only case that remains is that $htqwdbrm=bxvqcznt^{hrlmcgsp}$ is a positive power of a prime $bxvqcznt$ congruent to 5 or 7 (mod~8).  In this case, $htqwdbrm$ has two squarefree factors, $1$ and $bxvqcznt$, of which exactly one is congruent to $5$ or $7$ (mod~8).  We conclude that $zsdpnklt$ is odd in this case, as desired.\n\n\\noindent\n\\textbf{Second solution:}\n\nConsider the set $kprlqvzt$ of all integers in $\\{1,\\ldots,htqwdbrm-1\\}$ that are even and relatively prime to $htqwdbrm$.  Then the product of all elements in $kprlqvzt$ is\n\\[\n2^{\\phi(htqwdbrm)/2}\\prod_{{1\\leq lqtnfsvr\\leq (htqwdbrm-1)/2}\\atop{(lqtnfsvr,htqwdbrm)=1}} lqtnfsvr.\n\\]\nOn the other hand, we can rewrite the set of elements in $kprlqvzt \\pmod{htqwdbrm}$ as a set $mzxdfghu$ of residues in the interval $[-(htqwdbrm-1)/2,(htqwdbrm-1)/2]$.  Then for each $1\\leq lqtnfsvr\\leq (htqwdbrm-1)/2$ with $(lqtnfsvr,htqwdbrm)=1$, $mzxdfghu$ contains exactly one element from $\\{lqtnfsvr,-lqtnfsvr\\}$: if $-2vxmntjqp \\equiv 2dqrlhzvn \\pmod{htqwdbrm}$ for some $vxmntjqp,dqrlhzvn\\in\\{1,\\ldots,(htqwdbrm-1)/2\\}$, then $vxmntjqp \\equiv -dqrlhzvn \\pmod{htqwdbrm}$, which is impossible given the ranges of $vxmntjqp$ and $dqrlhzvn$.  Thus the product of all elements in $mzxdfghu$ is\n\\[\n(-1)^{vrhtclks} \\prod_{{1\\leq lqtnfsvr\\leq (htqwdbrm-1)/2}\\atop{(lqtnfsvr,htqwdbrm)=1}} lqtnfsvr,\n\\]\nwhere $vrhtclks$ denotes the number of elements of $kprlqvzt$ greater than $(htqwdbrm-1)/2$.\nWe conclude that $(-1)^{vrhtclks} \\equiv 2^{\\phi(htqwdbrm)/2} \\pmod{htqwdbrm}$.\n\nHowever, note that the number of elements of $kprlqvzt$ less than $(htqwdbrm-1)/2$ is equal to $zsdpnklt$, since dividing these numbers by 2 gives exactly the numbers counted by $zsdpnklt$. Hence the total cardinality of $kprlqvzt$ is $zsdpnklt + vrhtclks$; however, this cardinality also equals $\\phi(htqwdbrm)/2$ because the numbers in $\\{1,\\dots,htqwdbrm-1\\}$ relatively prime to $htqwdbrm$ come in pairs\n$\\{lqtnfsvr,htqwdbrm-lqtnfsvr\\}$ in each of which exactly one member is even. We thus obtain\n\\begin{align*}\n(-1)^{zsdpnklt} &= (-1)^{\\phi(htqwdbrm)/2 + vrhtclks} \\\\\n&\\equiv (-1)^{\\phi(htqwdbrm)/2} 2^{\\phi(htqwdbrm)/2} = (-2)^{\\phi(htqwdbrm)/2} \\pmod{htqwdbrm}.\n\\end{align*}\nIf $htqwdbrm=1$, then $zsdpnklt$ is even.  If $htqwdbrm$ has more than one prime factor, then the group $(\\mathbb{Z}/htqwdbrm\\mathbb{Z})^\\times$ has exponent dividing $\\phi(htqwdbrm)/2$, so $(-1)^{zsdpnklt}\\equiv (-2)^{\\phi(htqwdbrm)/2} \\equiv 1 \\pmod{htqwdbrm}$, and thus $zsdpnklt$ must be even in this case as well.  Finally, suppose that $htqwdbrm$ is a prime power $bxvqcznt^{hrlmcgsp}$ with $bxvqcznt$ odd and $hrlmcgsp$ positive.  Since $(\\mathbb{Z}/htqwdbrm\\mathbb{Z})^\\times$ is a cyclic group of order $\\phi(htqwdbrm)=bxvqcznt^{hrlmcgsp-1}(bxvqcznt-1)$, in which the only square roots of unity are $\\pm 1$, it follows that $(-2)^{\\phi(htqwdbrm)/2}\\equiv \\pm 1 \\pmod{htqwdbrm}$ in accordance with whether $(-2)^{(bxvqcznt-1)/2} \\equiv \\pm 1 \\pmod{bxvqcznt}$, i.e., whether $-2$ is a quadratic residue or nonresidue.  But recall that $-2$ is a quadratic residue modulo $bxvqcznt$ if and only if $bxvqcznt\\equiv 1, 3 \\pmod{8}$. Thus $zsdpnklt$ is odd in this case if and only if $bxvqcznt\\equiv 5$ or $7 \\pmod{8}$.\n\nWe conclude that for any odd integer $htqwdbrm\\geq 1$, the quantity $zsdpnklt$ is odd if and only if $htqwdbrm=bxvqcznt^{hrlmcgsp}$ with $hrlmcgsp$ positive and $bxvqcznt$ a prime that is 5 or 7 (mod~8).\n\n\\noindent\n\\textbf{Remark:} The combination of the two solutions recovers Gauss's criterion for when $-2$ is a quadratic residue modulo $bxvqcznt$, with essentially the original proof."
    },
    "kernel_variant": {
      "question": "Let q be an odd prime power, i.e. q = p^k with k ≥ 1 and p an odd prime.  Define the quantity\n        M_q = # { a ∈ ℤ : 0 < a < q/12 and gcd(a , q) = 1 } .\nShow that M_q is odd if and only if the prime p satisfies\n        p ≡ 13 , 17 , 19 or 23  (mod 24).",
      "solution": "We determine the parity of M_q.  All congruences are taken modulo 2 except where another modulus is explicitly indicated.\n\n1.  Inclusion–exclusion.\n   With μ the Möbius function we have\n      M_q = ∑_{d|q} μ(d) ⎣ q /(12d) ⎦ .             (1)\n   Because q = p^k is a power of a single prime, the only square–free divisors of q are d = 1 and d = p, so (1) reduces to\n      M_q ≡ ⎣ p^{k}/12 ⎦ + ⎣ p^{k-1}/12 ⎦   (mod 2).        (2)\n\n2.  The map ε(n).\n   For any integer n put ε(n) := ⎣ n/12 ⎦ (mod 2) ∈ {0,1}.  Adding 24 to n increases ⎣n/12⎦ by 2, hence ε(n) depends only on n (mod 24).  A direct check gives\n            ε(n) = 1 ⇔ n ≡ 12,13,…,23 (mod 24).             (3)\n   For odd n this produces the six residue classes\n            S := {13,15,17,19,21,23}  ⊂ ℤ/24ℤ.              (4)\n   (We do not claim that every element of S is a unit modulo 24.)\n\n3.  Residues of p^m modulo 24.\n   •  Primes p ≠ 3.\n      If p ≠ 3, then gcd(p,24) = 1, so p is a unit modulo 24.  The\n      group (ℤ/24ℤ)^× has exponent 2, hence p^2 ≡ 1 (mod 24).  Therefore\n            p^{m} ≡ { p   (m odd)\n                      1   (m even) }  (mod 24).             (5)\n   •  The prime p = 3.\n      Since 3^2 = 9 and 3·9 = 27 ≡ 3 (mod 24), we have\n            3^{m} ≡ { 3  (m odd)\n                       9  (m even) }  (mod 24).            (6)\n\n4.  Parity of M_q.\n   (a)  The case p = 3.\n        Using (6) in (2) and relation (3) we obtain\n           ε(3^{m}) = ε(3) = 0,  ε(3^{m-1}) ∈ { ε(3), ε(9) } = {0},\n        hence ε(3^{m}) + ε(3^{m-1}) ≡ 0 (mod 2).  Thus M_{3^{k}} is even for every k ≥ 1.\n\n   (b)  The case p ≠ 3.\n        From (5) we find\n           p^{k }   ≡   p   (resp. 1)  according as k is odd (resp. even),\n           p^{k-1} ≡   1   (resp. p)  according as k is odd (resp. even).\n        Exactly one of the two numbers p^{k}, p^{k-1} is congruent to p modulo 24; the other is congruent to 1.  Consequently, by (3)\n           ε(p^{k}) + ε(p^{k-1}) ≡ 1 (mod 2)  ⇔  p ∈ S.      (7)\n        Combining (2) with (7) we get\n              M_q odd  ⇔  p ∈ S  and  p ≠ 3.\n        Of the six classes in S, the residues 15 and 21 are divisible by 3 and hence contain no odd prime distinct from 3.  Therefore\n              p ∈ S, p ≠ 3  ⇔  p ≡ 13,17,19,23 (mod 24).\n\n5.  Conclusion.\n   We have shown that M_q is even when p = 3 and that, for any other odd prime p, the parity of M_q is odd exactly when p ≡ 13,17,19 or 23 (mod 24).  This completes the proof.",
      "_meta": {
        "core_steps": [
          "Use Möbius-inclusion to write N_q ≡ Σ_{d|q, squarefree} ⌊(q/d)/4⌋  (mod 2).",
          "Note that ⌊x/4⌋ (mod 2) depends only on x (mod 8): it is 1 exactly for residues 5,7.",
          "Hence N_q is odd ⇔ an odd number of square-free divisors q/d lie in the residue set {5,7} (mod 8).",
          "Show that if q contains (i) any prime ≡1 or 3 (mod 8) or (ii) two distinct primes ≡5 or 7 (mod 8), then those square-free divisors can be paired/quadrupled, so their contribution is even.",
          "Therefore N_q is odd only when q = p^k with p ≡5 or 7 (mod 8); in that case exactly one relevant divisor occurs, giving odd parity."
        ],
        "mutable_slots": {
          "slot1": {
            "description": "Denominator in the definition of the counting window (q/4). Any fixed even integer m≥2 would work, only altering the later modulus and residue set.",
            "original": "4"
          },
          "slot2": {
            "description": "Modulus used to classify residues; always 2·(slot1).",
            "original": "8"
          },
          "slot3": {
            "description": "Residue classes that make ⌊x/slot1⌋ odd. They are {slot2−3, slot2−1} when slot1=4, hence {5,7}.",
            "original": "{5,7} (mod 8)"
          },
          "slot4": {
            "description": "Congruence condition characterising the prime factor p; it lists exactly the classes in slot3.",
            "original": "p ≡ 5 or 7 (mod 8)"
          }
        }
      }
    }
  },
  "checked": true,
  "problem_type": "proof",
  "iteratively_fixed": true
}