# 2679 - Sucessor Par

## Descrição

{% embed url="<https://www.urionlinejudge.com.br/judge/pt/problems/view/2679>" %}

## Solução

Se o número for par, somar 2. Se o número for ímpar, somar 1.

Tem como fazer isso com apenas uma fórmula, independente do número `X` ser par ou ímpar:

$$
X - (X \text{ mod } 2) + 2
$$

Mas dá para fazer com condicional também, tudo bem.

{% tabs %}
{% tab title="C99" %}

```c
#include <stdio.h>

int main(){
    int X;

    scanf("%d", &X);

    printf("%d\n", X - (X % 2) + 2);

    return 0;
}
```

{% endtab %}

{% tab title="C++17" %}

```cpp
#include <iostream>

using namespace std;

int main(){
    int X;

    cin >> X;

    cout << X - (X % 2) + 2 << endl;

    return 0;
}
```

{% endtab %}

{% tab title="JavaScript 12.18" %}

```javascript
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

let X = parseInt(lines.shift().trim());

console.log(X - (X % 2) + 2);
```

{% endtab %}

{% tab title="Python 3.9" %}

```python
X = int(input())

print(X - (X % 2) + 2)
```

{% endtab %}
{% endtabs %}
