# Alternating function [closed]

This is a code golf challenge.

Only the shortest user-defined function in a language counts. This function should output (input/2)+2 for even numbers, and (input+1)/2 for odd numbers.

New contributor
name is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
• Welcome to Code Golf! For future reference, I highly recommend using the Sandbox before posting so you can get feedback, suggestions, and clarifications first. This challenge isn't very clear right now. What are acceptable inputs (numbers? integers? positive integers? etc). Also, I advise against specifying "user-defined function". We have default standards for input/output that fit almost all challenges and this restriction will prevent languages without the ability to define functions from competing. – hyper-neutrino Jun 9 at 21:39
• This is OEIS A028242, albeit offset to start at input -2 by your formula. If you want to restructure this challenge like a sequence, take a look at some of the other sequence challenges on our site; you should be able to get a good idea of the typical structure of these types of challenges. Otherwise, you'll need to clarify the range of valid inputs. Otherwise, this challenge is simple enough to be pretty clear, although some test cases are never a bad idea. – hyper-neutrino Jun 9 at 21:50