[Question]
  [
Given an input `n`, your program or function must output the smallest positive integer `k` such that `n` rounded to the nearest multiple of `k` is greater than `n`. 
### Example.
Given an input `20`, the output value should be `3`:
* The nearest multiple of `1` is `20`, which is **not** greater than `20`.
* The nearest multiple of `2` is `20`, which is **not** greater than `20`.
* The nearest multiple of `3` is `21`, which **is** greater than `20`, so it is output.
### Test Cases
```
#Input  #Output
2       3
4       5
6       4
8       3
10      4
12      7
14      3
16      6
18      4
20      3
22      4
24      5
26      3
28      5
30      4
32      3
34      4
36      8
38      3
40      6
42      4
44      3
46      4
48      5
50      3
52      6
54      4
56      3
58      4
60      7
62      3
64      5
66      4
68      3
70      4
72      11
74      3
76      6
78      4
80      3
82      4
84      5
86      3
88      5
90      4
92      3
94      4
96      7
98      3
1000    6
```
The output given any odd input should be 2.
### Rules
* `n` is a positive integer less than `2^32`
* rounding is performed such that if two multiples of `k` are equally distant from `n`, the greater one is chosen (["round halves up"](https://en.wikipedia.org/wiki/Rounding#Round_half_up)). In this way, every odd `n` yields an output of `2`.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest code **in each language** wins.
  
[Answer]
# [Python 3](https://docs.python.org/3/), 48 38 bytes
**Edit:** -10 bytes by using recursion
```
l=lambda x,y=2:y*(x%y>=y/2)or l(x,y+1)
```
[Try it online!](https://tio.run/##K6gsycjPM/7/P8c2JzE3KSVRoUKn0tbIqlJLo0K10s62Ut9IM79IIUcDKKxtqPk/DcjJVMjMUyhKzEtP1TDUMTQwMNS04uIsKMrMK9HI1AEqzdTU/A8A)
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 6 bytes
```
@<rX}a
```
[Try it online!](https://tio.run/##y0osKPn/38GmKKI28f9/QwMA)
## Explanation:
```
@    <r X}a
XYZ{U<UrX}a
X              // X = 0; Increments when the condition in between {...} fails
   {     }a    // Return the first integer X where:
    U          //   The input
     <U        //   is less than the input
       rX      //     rounded to the nearest multiple of X
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 13 bytes
```
tQ:yy/Yo*<fX<
```
[Try it online!](https://tio.run/##y00syfn/vyTQqrJSPzJfyyYtwub/f0MDAwMA) Or [verify all inputs from `1` to `1000`](https://tio.run/##y00syflvaGBgYKXk8L8k0KqyUj8yX8smLcLm/38A).
### Explanation
Consider input `6`.
```
t      % Implicit input. Duplicate
       % STACK: 6, 6
Q:     % Add 1, range
       % STACK: 6, [1 2 3 4 5 6 7]
yy     % Duplicate top two elements
       % STACK: 6, [1 2 3 4 5 6 7], 6, [1 2 3 4 5 6 7]
/      % Divide, element-wise
       % STACK: 6, [1 2 3 4 5 6 7], [6 3 2 1.5 1.2 1 0.8571]
Yo     % Round to closest integer. Halves are rounded up
       % STACK: 6, [1 2 3 4 5 6 7], [6 3 2 2 1 1 1]
*      % Multiply, element-wise
       % STACK: 6, [6 6 6 8 5 6 7]
<      % Less than, element-wise
       % STACK: [0 0 0 1 0 0 1]
f      % Find: indices of nonzeros (1-based)
       % STACK: [4 7]
X<     % Minimum of vector. Implicit display
       % STACK: 4
```
[Answer]
# [Python 2](https://docs.python.org/2/), 35 bytes
```
f=lambda n,i=1:n%i*2/i or-~f(n,i+1)
```
[Try it online!](https://tio.run/##DcgxDoAgDADAWV/RxQQUI2Uk4TEYRZtoIYTFxa9Xb7zytDOzE0nhive6RWBDAT0PNLqFINf5Teq/CbWkXIGAGGrkY1do0Frt@65U4gZkICnS8gE "Python 2 – Try It Online")
[Answer]
# JavaScript (ES6), ~~28~~ 25 bytes
```
n=>g=x=>n%x>=x/2?x:g(-~x)
```
* 3 bytes saved thanks to Arnauld.
---
## Test it
```
o.innerText=(f=
n=>g=x=>n%x>=x/2?x:g(-~x)
)(i.value=64)();oninput=_=>o.innerText=f(+i.value)()
```
```
<input id=i type=number><pre id=o>
```
Or test all numbers from 1-1000 (Give it a minute to run):
```
f=n=>g=x=>n%x>=x/2?x:g(-~x);[2,3,2,5,2,4,2,3,2,4,2,7,2,3,2,6,2,4,2,3,2,4,2,5,2,3,2,5,2,4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[Answer]
# [Proton](https://github.com/alexander-liao/proton), 33 bytes
```
n=>[x for x:2..n+2if n%x>=x/2][0]
```
[Try it online!](https://tio.run/##FcmxCoAgEADQ3a@4JVASU0dBfyQcGjJuOUUchOjbr3rra72OSlwiU0z7hFI7zOCNodVjAVpminPzebeZ/0MI0A@6Tum0s07BLeDTOtKQqKFIVEo8/AI "Proton – Try It Online")
[Answer]
# [Pyth](https://pyth.readthedocs.io), ~~12~~ 11 bytes
```
hfgy%QTTm+2
```
**[Try it here.](https://pyth.herokuapp.com/?code=hfgy%25QTTm%2B2&input=20&test_suite=1&test_suite_input=1%0A2%0A3%0A4%0A5%0A6&debug=0)**
[Answer]
# [Proton](https://github.com/alexander-liao/proton), 33 bytes
```
x=>[y for y:2..x+2if x%y>=y/2][0]
```
[Try it online!](https://tio.run/##KyjKL8nP@59j@7/C1i66UiEtv0ih0spIT69C2ygzTaFCtdLOtlLfKDbaIPY/SC5TwUqhKDEvPVXDUMfQwFBToZpLAQgKijLzSjSKS4o0MjX1crJKi0s0TDR1FHKAXE2u2v8A "Proton – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 11 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
÷R%1<.¬;1TṂ
```
A monadic link taking and returning positive integers.
**[Try it online!](https://tio.run/##y0rNyan8///w9iBVQxu9Q2usDUMe7mz6//@/CQA "Jelly – Try It Online")** or see a [test suite](https://tio.run/##AUMAvP9qZWxsef//w7dSJTE8LsKsOzFU4bmC/8W8w4figqwKNTBS4bikO8i3w4csQCIxMDFSbTLCpMOHwqRq4oKs4oCdfEf/ "Jelly – Try It Online").
### How?
```
÷R%1<.¬;1TṂ - Link: number, n       e.g. 10
 R          - range(n)               [ 1,2,3     ,4  ,5,6     ,7     ,8   ,9     ,10]
÷           - n divided by           [10,5,3.33..,2.5,2,1.66..,1.42..,1.25,1.11..,1 ]
  %1        - modulo by 1            [ 0,0,0.33..,0.5,0,0.66..,0.42..,0.25,0.11..,0 ]
    <.      - less than 0.5?         [ 1,1,1     ,0  ,1,0     ,1     ,1   ,1     ,1 ]
      ¬     - not                    [ 0,0,0     ,1  ,0,1     ,0     ,0   ,0     ,0 ]
       ;1   - concatenate a 1        [ 0,0,0     ,1  ,0,1     ,0     ,0   ,0     ,0 , 1]
         T  - truthy indices         [            4    ,6                           ,11]
          Ṃ - minimum                4
```
Note: The concatenation of `1` is just to handle the cases where `n` is one of `1` ,`2`, or `4` when the result needs to be `n+1` (`‘R÷@%1<.¬TṂ` would also work).
[Answer]
# [Haskell](https://www.haskell.org/), ~~33~~ 32 bytes
```
f n=[i|i<-[1..],2*mod n i>=i]!!0
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P00hzzY6sybTRjfaUE8vVsdIKzc/RSFPIdPONjNWUdHgf25iZp6CrUJuYoGvgkZMnq5dQVFmXomKRp6OAlCvpqZCtJGOiZ6euUHsfwA "Haskell – Try It Online")
*Saved one byte thanks to w0lf*
[Answer]
# Dyalog APL, ~~23~~ 22 bytes
```
{⊃x/⍨⍵<x×⌊.5+⍵÷x←⍳1+⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R24TqR13NFfqPelc86t1qU3F4@qOeLj1TbSDn8PYKoPSj3s2GIF4tULXCIaCizcYGAA)
[Answer]
# Pyth, 5 bytes
```
fgy%Q
```
[Test suite](https://pyth.herokuapp.com/?code=fgy%25Q&input=20&test_suite=1&test_suite_input=1%0A2%0A3%0A4%0A5%0A6%0A8%0A10%0A12&debug=0)
No rounding builtins, just checking for the first positive integer T, where double the input mod T is greater than or equal to T.
Explanation:
```
fgy%Q
fgy%QTT    Implicit variable introduction.
f          Find the first positive integer T such that the following is truthy:
   %QT     Input % T
  y        Doubled
 g    T    Is greater than or equal to T
```
[Answer]
# x86 Machine Code, 17 bytes
This code implements a basic, iterative solution in the form of a reusable function:
```
31 F6                   xor    esi, esi
46                      inc    esi         ; set ESI (our temp register) to 1
                     Loop:
89 C8                   mov    eax, ecx    ; copy 'n' to EAX for division
46                      inc    esi         ; eagerly increment temp
99                      cdq                ; extend EAX into EDX:EAX
F7 F6                   div    esi         ; divide EDX:EAX by ESI
01 D2                   add    edx, edx    ; multiply remainder by 2
39 F2                   cmp    edx, esi    ; compare remainder*2 to temp
7C F4                   jb     Loop        ; keep looping if remainder*2 < temp
96                      xchg   eax, esi    ; put result into EAX (1 byte shorter than MOV)
C3                      ret
```
The function follows the [fastcall calling convention](https://en.wikipedia.org/wiki/X86_calling_conventions#Microsoft_fastcall), so that the single parameter (`n`) is passed in the `ECX` register. The return value (`k`) is, per usual, returned in the `EAX` register.
[Try it online!](https://tio.run/##nY9NbsIwEIXX8SlGqSrZFKqQIH4aYJMWiVUP0FSRsZ1gKTgodlCkiqs3nZCy6q4L672x3/ibEZNCiK4TlbEOxJHX0C7nSSXVxydswE/baJq2u3nazvAsV2mbLAe/Qr9bDG8BZl5DzPZ3qIsEdYYZfEsiPybWcacFNMbqwigJWcadq/WhcSrLKM25dYKXJWNAR8jftYbRe5jhHL8zxd2DNqJspIK1dVJXz8ct0cbBiWtDe8PrQoyHPUYjLC6MfBHv3DhL/beLMrA3ffHis5h4eVXDrUsjIoxR1huYBgG6p03IiIet3rnGRE79R5m6yTZ1qMYfgx7DMCjVrP/rSu6Y1LxLeecAtceqKSXgdnBQELK/5OmNDNE/uR7xauWa2kAQk2v3LfKSF7abnKLwBw "C (gcc) – Try It Online")
[Answer]
# Java 8, 42 bytes
Lambda from `Integer` to `Integer`.
```
n->{for(int f=1;;)if(n%++f*2>=f)return f;}
```
[Try It Online](https://tio.run/##TU9Na8MwDD0nv0IUAvGSmq29zU2Ogx12KuwydvASOyhz7ODIgVLy2zN3zWAg0BPS@1AvZ7l3o7J9@72O4ctgA42R0wRvEi1c02T0OEtSMJGkuOwjgQdCw3WwDaGz/GUDp1dLqlO@hA3U4F2w7bs0QUG12n191c7naAl09SQEQ53brCj0w6GuNPOKgregxbImIo3O9zib8eywhSGGys/k0XYfnyB9N7FbxiTKwq8uQgUHEdsJjo@3XsT5fpOcLxOpgbtAPD5lyfxJ8UgfJOW7rIVnyNpdCVj@y87lOJpLjowxEYWWNNay/gA)
## Acknowledgments
* -1 byte thanks to *Kevin Cruijssen*
[Answer]
# [Perl 5](https://www.perl.org/), 24 + 1 (-p) = 25 bytes
```
1while$_%++$k<$k/2;$_=$k
```
[Try it online!](https://tio.run/##K0gtyjH9/9@wPCMzJ1UlXlVbWyXbRiVb38haJd5WJfv/fzNTY2MzC/N/@QUlmfl5xf91CwA "Perl 5 – Try It Online")
Tries each integer `$k` starting at 1 until it finds a remainder that is at least half of `$k`.
[Answer]
# [Forth (gforth)](http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/), 45 bytes
```
: f 1 begin 1+ 2dup mod over 1+ 2/ >= until ;
```
[Try it online!](https://tio.run/##XcuxCoMwGEXhvU9xcBXTROhiqS8iWWqMDai/BPX1U83odOHjXC9x@1WjvyalBo/hO4xhwZTUbl@ZxSHHEDM8aT/syxYm3sloTU3nxNIFywsVUQVULUUWj6KPV1NOIqt9nA996zKdYfoD "Forth (gforth) – Try It Online")
### Code Explanation
```
: f             \ start a new word definition
  1             \ start a counter at 1
  begin         \ start an indefinite loop
    1+          \ add 1 to counter
    2dup mod    \ duplicate input value and counter, get remainder of input/counter
    over 1+ 2/  \ get counter/2 (add 1 to force rounding up)
    >=          \ check if remainder is greater than counter/2
  until         \ end loop if true, otherwise go back to beginning
;               \ end word definition
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 9 bytes
```
∞.ΔIs/Dò‹
```
[Try it online!](https://tio.run/##yy9OTMpM/f//Ucc8vXNTPIv1XQ5vetSw8/9/EwA "05AB1E – Try It Online")
## Explanation
```
∞.ΔIs/Dò‹ Full code
∞.Δ       Returns the first number for which the following code returns true
             -> stack is [n]
   Is     Push the input and swap the stack -> stack is [input, n]
     /    Divide both of them -> stack is [input/n]
      Dò  Duplicate and round the second -> stack is [input/n, rounded(input/n)]
        ‹ Check if input/n got larger by rounding -> stack is [bool]
             -> if bool is true, abort and return the current number
```
[Answer]
# [Rockstar](https://github.com/RockstarLang/rockstar), 681 bytes
```
Thought takes Patience and Control
While Patience is as high as Control
Let Patience be without Control
Give back Patience
Rock takes Art
Love is neverending
Sex is bottomless
Put Thought taking Art & Love into your head
If your head is Sex
Give back Art
Else
Limits are inspiration
Put Art with Limits without your head into the rubbish
Give back the rubbish
Listen to Chance
Questions are unstoppable
Until Questions is Chance
Build Questions up
Put Thought taking Chance, Questions into your mind
Answers are independence (but)
Put Questions over Answers into the world
Put Rock taking the world into the world
If your mind is as big as the world
Say Questions
Break it down
```
You can [try rockstar online](https://codewithrockstar.com/online), but you'll need to copy and paste the code across. It will prompt you for an input number.
I didn't go for lowest byte count , because Rockstar is obviously not made for golfing, so instead I tried to go for Rock 'n' Roll lyrics. 
## Explanation:
This is based on the same solution as others (python, java):
```
Iterate up from 2:
if n % iterator >= ceil(n/2)
    return iterator
```
First I need to define modulus and ceiling functions though, which for poetry's sake are called Thought and Rock.
The below is a less poetic version with different variable names, and explanations where the syntax is unclear. Parentheses denote comments.
```
Modulus takes Number and Divisor
While Number is as high as Divisor
Put Number minus Divisor into Number
    (blank line ending While block)
Give back Number (return Number)
    (blank line ending function declaration)
Ceil takes Decimal
Put Modulus taking Decimal, 1 into Remainder
If Remainder is 0
Give back Decimal (return Decimal)
Else
Put Decimal with 1 minus Remainder into Result
Give back Result (return Result)
    (blank line ending if block)
    (blank line ending function declaration)
Listen to Input (Read from STDIN to Input)
Index is 1
Until Index is Input
Build Index up (Increment by 1)
Put Modulus taking Input, Index into LHS
Put Index over 2 into RHS
Put Ceil taking RHS into RHS
If LHS is as big as RHS
Say Index
Break it down (Break from loop)
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 18 bytes
```
ɓ÷Ḟ,¥Ċ$×ạÐṂ⁸Ṁ>⁸µ1#
```
[Try it online!](https://tio.run/##ATAAz/9qZWxsef//yZPDt@G4nizCpcSKJMOX4bqhw5DhuYLigbjhuYA@4oG4wrUxI////zE "Jelly – Try It Online")
Full program.
[Answer]
# [Swift 3](https://www.swift.org), 51 bytes
```
{n in(2..<n+2).filter{Float(n%$0)>=Float($0)/2}[0]}
```
For some *extremely* bizarre reasons, `[0]` doesn't work online. Here is the online compiler-compatible version (that uses `.first!` instead):
```
{n in(2..<n+2).filter{Float(n%$0)>=Float($0)/2}.first!}
```
**[Test Suite (online-compatible).](http://swift.sandbox.bluemix.net/#/repl/5994a31a83068d0a59311b80)**
[Answer]
# [C# (Mono)](http://www.mono-project.com/), 39 bytes
```
n=>{int i=1;for(;n%++i*2<i;);return i;}
```
[Try it online!](https://tio.run/##HYw/C8IwEMX3@xS3CIlV0Tpe00VwUhAcnEtM5aC9QJIKUvrZY3R5P94fno3b0YvPU2R54f0TkxsJwA5djHiDGWLqElt8e37itWNRuoTnSWzDkjZYpMUeTRbTzsUgmwP1PiiSVVXxum6YNAWXpiDItORyXmpU/y0arKmgweP@x6p4DScv0Q9u9wic3IXFqV6x1gQLLPkL "C# (Mono) – Try It Online")
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 7 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
ç&╬▼⌐╔ñ
```
[Run and debug it](https://staxlang.xyz/#p=8726ce1fa9c9a4&i=2%0A4%0A6%0A8%0A10%0A12%0A14%0A16%0A18%0A20%0A22%0A24%0A26%0A28%0A30%0A32%0A34%0A36%0A38%0A40%0A42%0A44%0A46%0A48%0A50%0A52%0A54%0A56%0A58%0A60%0A62%0A64%0A66%0A68%0A70%0A72%0A74%0A76%0A78%0A80%0A82%0A84%0A86%0A88%0A90%0A92%0A94%0A96%0A98%0A1000&a=1&m=2)
]