Problème
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.
Contraintes
1 ≤ width, height ≤ 1,000,000
Exemples
Entrée :
width = 3
height = 5
Sortie attendue :
expected = 16
Entrée :
long long width = 3;
long long height = 5;
Sortie attendue :
long long expected = 16;
Entrée :
long width = 3;
long height = 5;
Sortie attendue :
long expected = 16;
Explication
Two sides of 3 and two sides of 5: 3 + 3 + 5 + 5 = 16.
Entrée :
width = 7
height = 7
Sortie attendue :
expected = 28
Entrée :
long long width = 7;
long long height = 7;
Sortie attendue :
long long expected = 28;
Entrée :
long width = 7;
long height = 7;
Sortie attendue :
long expected = 28;
Explication
A square is a rectangle too: 4 × 7 = 28.
Références
Ce défi a été adapté pour CodeUtility. Suivez l'énoncé et les contraintes ci-dessus.