Minimum Cuts to Divide a Circle

A valid cut in a circle can be:

  • A cut that is represented by a straight line that touches two points on the edge of the circle and passes through its center.
  • A cut that is represented by a straight line that touches one point on the edge of the circle and its center.

Given the integer n, return the minimum number of cuts needed to divide a circle into n equal slices.

Example 1
Inputn = 4
Output2
The figure shows how cutting the circle twice through the middle divides it into 4 equal slices.
Example 2
Inputn = 3
Output3
At least 3 cuts are needed to divide the circle into 3 equal slices, and fewer cuts cannot result in 3 slices of equal size and shape.

Constraints

  • 1 <= n <= 100

Asked at 5 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate