A cyclic number is an integer in which cyclic permutations of the digits are successive multiples of the number. The most widely known is the six-digit number 142857 (Please see below explanation given in examples).
The following trivial cases are typically excluded for Cyclic Numbers.
- Single digits, e.g.: 5
- Repeated digits, e.g.: 555
- Repeated cyclic numbers, e.g.: 142857142857
Given a number, check if it is cyclic or not.
Input : 142857 Output : Yes Explanation 142857 × 1 = 142857 142857 × 2 = 285714 142857 × 3 = 428571 142857 × 4 = 571428 142857 × 5 = 714285 142857 × 6 = 857142
We generate all cyclic permutations of the number and check if every permutation divides number of not. We also check for three conditions. If any of the three conditions is true, we return false.
This article is contributed by Ajay Puri. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above..
- Generate all cyclic permutations of a number
- Number Theory | Generators of finite cyclic group under addition
- Exterior angle of a cyclic quadrilateral when the opposite interior angle is given
- Count number of trailing zeros in Binary representation of a number using Bitset
- Count number of triplets with product equal to given number with duplicates allowed | Set-2
- Count number of triplets with product equal to given number with duplicates allowed
- Find minimum number to be divided to make a number a perfect square
- Number of times the largest perfect square number can be subtracted from N
- Number of possible permutations when absolute difference between number of elements to the right and left are given
- Given number of matches played, find number of teams in tournament
- Minimum number of given powers of 2 required to represent a number
- Number of digits to be removed to make a number divisible by 3
- Count Number of animals in a zoo from given number of head and legs
- Find count of digits in a number that divide the number
- Queries on sum of odd number digit sums of all the factors of a number