Digit Rotation Number

Medium
math digit-manipulation cycle-detection rotation
Problem Description

Rotate the digits of a number by one position to the left each time until the number repeats (forms a cycle). Count how many rotations are needed to return to the original number.

Input Format
A single positive integer.
Output Format
Number of rotations needed to return to the original number.
Constraints
• 1 ≤ number ≤ 10^6
• Rotation moves leftmost digit to rightmost position
• Example: 123 → 231 → 312 → 123
• Count rotations until original number appears
• Handle single digit numbers (cycle length 1)
Sample Input/Output
Input:
123
Output:
3
Explanation

Rotations: 123 → 231 → 312 → 123. Takes 3 rotations to return to original.

Solution Hints
80
Points
2000ms
Time Limit
128MB
Memory Limit
Code Editor
Register to Submit
Register to Access Code Editor

Create a free account to solve coding problems and track your progress.

Register Now
Feedback