I am working on a C# program where I need certain numbers for formatting a printable string. This will help me in determining on how many /r/n I need to add between different datasets internally.
It is in WinForms.
public int GiveMeOutput(int input)
{
int output = 2;
//logic here
return output;
}
Can anyone help me in any language for the logic?
Greatly appreciate your help.
I would be getting the input into a Function(int input) & it should throw the "int" output.
Below is the table I want
| Input | Output |
|---|---|
| 5 | 2 |
| 6 | 2 |
| 7 | 3 |
| 8 | 3 |
| 9 | 4 |
| 10 | 4 |
| 11 | 5 |
| 12 | 5 |
| 13 | 6 |
| 14 | 6 |
| …continues | …continues |
>Solution :
This should do the trick:
int Map(int input)
{
return (input - 2 + input % 2) / 2;
}
Subtract 2, add 1 to odd numbers, then divide by 2.