N numbers closest to zero staying balanced Objective: Given a positive integer n:


If n is odd, output the list of n numbers closest to 0 in increasing order
If n is even, output a Falsey value.


Test cases:

5 -&gt; [-2,-1,0,1,2]
4 -&gt; false (or any Falsey value)
1 -&gt; [0]




Reference implementation



function update(){
  var num = +document.getElementById("yield").value;
  if(num){
    var out = document.getElementById("output");
    if(num % 2 == 1){
      // base is balanced
      var baseArr = [];
      for(var i=0;i&lt;num;i++){
        baseArr.push(i-Math.floor(num/2));
      }
      out.innerHTML = baseArr.join(" ");
    } else {
      out.innerHTML = "false";
    }
  } else {
    out.innerHTML = "&lt;i&gt;enter input&lt;/i&gt;";
  }
}

setInterval(update,1);
* {
  font-family: "Constantia", "Consolas", monospace;
}

[type="number"] {
  width: 10px;
  width: 2em;
}

#output {
  font-family: "Consolas", monospace;
}
Input: &lt;input type="number" id="yield" value="3"&gt; is &lt;span id="output"&gt;&lt;i&gt;enter input&lt;/i&gt;&lt;/span&gt;
Pyth, 10 bytes

*-R/Q2Q%Q2


Try it online.

How it works

            (implicit) Store the input in Q.
   /Q2      Calculate Q/2 (integer division).
 -R   Q     Subtract that value (-R) from each element in [0, ..., Q-1] (Q).
*      %Q2  Repeat the resulting array Q%2 times.