Todos los desafíos
Fácil 0 resueltos 0% de aceptación

Rectangle Perimeter

Compute the perimeter of a rectangle from its sides.

Problema

A rectangle has two sides of length width and two sides of length height. Its perimeter is the total length of all four sides.

Implement rectangle_perimeter(width, height).

Input

width: The width of the rectangle. height: The height of the rectangle.

Output

Return the perimeter as an integer.

Restricciones

1 ≤ width, height ≤ 1,000,000

Ejemplos

Ejemplo 1
Entrada:
width = 3
height = 5

Salida esperada:
expected = 16
Entrada:
long long width = 3;
long long height = 5;

Salida esperada:
long long expected = 16;
Entrada:
long width = 3;
long height = 5;

Salida esperada:
long expected = 16;

Explicación

Two sides of 3 and two sides of 5: 3 + 3 + 5 + 5 = 16.

Ejemplo 2
Entrada:
width = 7
height = 7

Salida esperada:
expected = 28
Entrada:
long long width = 7;
long long height = 7;

Salida esperada:
long long expected = 28;
Entrada:
long width = 7;
long height = 7;

Salida esperada:
long expected = 28;

Explicación

A square is a rectangle too: 4 × 7 = 28.

Referencias

Este reto está adaptado para CodeUtility. Sigue el enunciado y las restricciones indicadas arriba.

Aprende de otros

Soluciones de la comunidad

Aún no hay soluciones publicadas. Resuelve este reto para compartir la primera.