Minimum Cuts to Divide a Circle - Problem

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, or
  • 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.

Input & Output

Example 1 — Four Equal Slices
$ Input: n = 4
Output: 4
💡 Note: To divide a circle into 4 equal slices, we need 4 cuts through the center. Each cut creates one slice boundary.
Example 2 — Single Slice
$ Input: n = 1
Output: 0
💡 Note: For 1 slice (the whole circle), no cuts are needed.
Example 3 — Three Equal Slices
$ Input: n = 3
Output: 3
💡 Note: To create 3 equal slices, we need 3 cuts, each at 120° angles from each other through the center.

Constraints

  • 1 ≤ n ≤ 106

Visualization

Tap to expand
Minimum Cuts to Divide Circle: n=4 → 4 cutsInput: n = 4Whole circleNeed 4 equal slicesProcess: Make 4 cuts4 cuts through centerCreates 4 equal slicesOutput: 4Answer4Minimum cuts neededFormula: cuts = (n == 1) ? 0 : n
Understanding the Visualization
1
Input
Number of equal slices needed: n = 4
2
Process
Each cut creates one slice boundary
3
Output
Minimum cuts needed: 4
Key Takeaway
🎯 Key Insight: Each cut through the center creates exactly one slice boundary, so n slices require n cuts (except n=1 needs 0 cuts)
Asked in
Google 15 Microsoft 12
23.4K Views
Medium Frequency
~5 min Avg. Time
892 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen