Einfach 1 gelöst 100.0% Erfolgsquote

Rectangle Perimeter

Compute the perimeter of a rectangle from its sides.

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.

Einschränkungen

1 ≤ width, height ≤ 1,000,000

Beispiele

Beispiel 1
Eingabe:
width = 3
height = 5

Erwartete Ausgabe:
expected = 16
Eingabe:
long long width = 3;
long long height = 5;

Erwartete Ausgabe:
long long expected = 16;
Eingabe:
long width = 3;
long height = 5;

Erwartete Ausgabe:
long expected = 16;

Erläuterung

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

Beispiel 2
Eingabe:
width = 7
height = 7

Erwartete Ausgabe:
expected = 28
Eingabe:
long long width = 7;
long long height = 7;

Erwartete Ausgabe:
long long expected = 28;
Eingabe:
long width = 7;
long height = 7;

Erwartete Ausgabe:
long expected = 28;

Erläuterung

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

Referenzen

Diese Aufgabe wurde für CodeUtility angepasst. Beachte die oben genannten Vorgaben und Einschränkungen.

Von anderen lernen

Community-Lösungen

Achtung Spoiler: 1 vollständige Lösung unten Versuche es zuerst selbst zu lösen. Du kannst trotzdem einen Blick auf den Code und die KI-Reviews anderer Entwickler werfen. Melde dich an und löse die Aufgabe, um an der Diskussion teilzunehmen.