Thread: Cyclic number question

  1. #1
    Registered User
    Join Date
    Apr 2017
    Posts
    1

    Cyclic number question

    I have an exercise about cyclic number but I haven't found the solution yet. Can you help me on it.
    This is the problem.
    Print out the maximum value of number base b (1 < b < x) so that there exists a positive cyclic number of length n under base b. Note that leading-zeroes are allowed.
    Input: two integers n and x (1 <= n <= 5*10^6, 2 <= x <= 10^9)
    Output: print a single integer - the largest b that exists. If no such b exists, print -1.

    Thanks in advance!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    You mean one of these ?
    Cyclic number - Wikipedia

    Scroll down to "Construction of cyclic numbers" and think about it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Cyclic function
    By Laurentiu Dobre in forum C Programming
    Replies: 12
    Last Post: 02-16-2017, 12:18 PM
  2. how to find if array is cyclic
    By SA80 in forum C Programming
    Replies: 3
    Last Post: 05-05-2012, 03:53 AM
  3. Cyclic dependencies, observer, or...
    By g4j31a5 in forum C++ Programming
    Replies: 7
    Last Post: 12-13-2011, 05:45 AM
  4. cyclic buffer
    By Fortune in forum C Programming
    Replies: 2
    Last Post: 04-23-2009, 05:19 AM
  5. Need a little help with Cyclic Numbers Program
    By SlyMaelstrom in forum C++ Programming
    Replies: 3
    Last Post: 10-19-2005, 05:01 PM

Tags for this Thread