← Unit 1 · all exercises
Saved in this browser only

Perimeter of a rectangle

Return the distance all the way around a rectangle: two widths plus two heights.

int perimeter(int width, int height)

Solution.java
Loading editor…
Results

Examples

  • perimeter(3, 4) → 14
  • perimeter(5, 5) → 20

There are also 3 hidden tests you can't see. Solve the problem, not the examples.