Cyclic Numbers
Time limit1sMemory limit512 MB
Given a list of digit strings up to 1000 digits long, the task checks whether each number is cyclic, meaning its multiples by 1 to n are rotations of its digits.
- Level
Easy3 of 10
- Topics
- String, Simulation, Implementation
- Solved
- No attempts yet
Problem
A cyclic number is a positive integer digits in length which, when multiplied by any integer from 1 to , yields a "cycle" of the digits of the original number. That is, if you consider the number after the last digit to "wrap around" back to the first digit, the sequence of digits in both numbers will be the same, though they may start at different positions.
For example, the number 142857 is cyclic:
Write a program that determines whether each number is cyclic.
Input
The input is a list of integers, each with 2 to 1000 digits. Leading zeroes are allowed.
Output
For each integer, display the integer and whether or not it is cyclic.