Rectangle Perimeter

Given separate positive integer width and height values in the same length unit, return the distance around the rectangle in that unit. Add one width and one…

Given separate positive integer width and height values in the same length unit, return the distance around the rectangle in that unit. Add one width and one height, then double their sum.

1 <= width <= 46,340 and 1 <= height <= 46,340. Both are exact integers. Return a perimeter from 4 through 185,360.

Example 1: input width = 3, height = 5; output 16. The adjacent sides sum to 8, and doubling that sum gives 16.

Example 2: input width = 8, height = 3; output 22. The adjacent sides sum to 11, and doubling that sum gives 22.

Example 3: input width = 1, height = 1; output 4. A unit square has four sides of length 1.

Category: Math & Numbers. Topic: math. Difficulty: Easy. Patterns: math.