I came up with the following in GNU C


One could argue there is a branch here a&1?0:b

So I also came up with this one


I'm depending on implicit int here as well.

Can you make it any smaller?

Explanation of the above code, or at least parts of how I got there can be found here http://codepad.org/L0MvnCe9

Must not use function calls (recursion, standard library functions like fma, exp, etc), loops (while, for, do), or branches (if, ?:, etc). No using the divide or multiply operator either (that's cheating.) goto is allowed for branching.

Good luck!


closed as unclear what you're asking by Ypnypn, Martin Ender, ProgramFOX, matsjoyce, NinjaBearMonkey Nov 10 '14 at 20:16

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 14
    \$\begingroup\$ goto is a branch. \$\endgroup\$ – feersum Nov 10 '14 at 9:03
  • 1
    \$\begingroup\$ It's just an obfuscated form of if(a<1)goto x;. If an exact list of operators, keywords etc. which can't be used is provided it could be a valid code golf problem though. \$\endgroup\$ – feersum Nov 10 '14 at 9:12
  • 2
    \$\begingroup\$ @Tal It's simple but tedious to do it without any branch, as long as the size of int is known, by calculating each of the n bits from the n^2 interactions between bits. \$\endgroup\$ – feersum Nov 10 '14 at 10:39
  • 3
    \$\begingroup\$ Is C the only allowed language? \$\endgroup\$ – ProgramFOX Nov 10 '14 at 10:46
  • 1
    \$\begingroup\$ Could you rearrange the information a bit, as it took me a while to see what the rules are. Also, how does the code pad link give explanation? Since it's quite small, you could move it into the question as well. \$\endgroup\$ – matsjoyce Nov 10 '14 at 19:23