Results 1 to 8 of 8

Thread: Repeated numbers in a sequence

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2005
    Posts
    1

    Question Repeated numbers in a sequence

    the problem is:
    I want to know if there is any way to find repeated digits in a number sequence. for example : 12341 there are two "1's" and in 11 we can find two "1's" also. Is there some mathematical reason between them valid for any number sequence?

    I cant use array's or vector's of any kind and I also can't use String. I think this is only a maths problem. Can any one help me?!

  2. #2
    Addicted Member Rassis's Avatar
    Join Date
    Jun 2004
    Location
    Lisbon
    Posts
    248

    Re: Repeated numbers in a sequence

    If you are allowed to use Excel and if you enter each digit of a number in a single cell, it will be quite easy to calculate the quantity of each figure (from 0 to 9) which exists in that number. I don’t think there is any other possible way…
    ...este projecto dos Deuses que os homens teimam em arruinar...

  3. #3
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: Repeated numbers in a sequence

    Here's an algorithm that may be able to help.

    Number: n.

    Repeat these steps Int(Log(n)) + 1 times. The current repition you are on is "k," starting from 0.

    1. Find out which numeral (from 0-9) is in the kth position (ones, tens, hundreds place, etc.) of the number. In VB, this would be equal to Int(n \ (10k)) Mod 10.

    2. The expression in number 1 will give you a number from 0-9. Keep track of how many times you've gotten each digit and you'll get your answer in the end.

    Example:
    12341

    Repeat Int(4.091) + 1 = 5 times.

    Int(12341 \ 1) Mod 10 = 1.

    Tally:
    1 1's, 0 everything else.

    Int(12341 \ 10) Mod 10 = 4.

    Tally:
    1 1's, 1 4's, 0 everything else.

    Etc. through

    Int(12341 \ 10000) Mod 10 = 1.

    Tally:
    2 1's, 1 4's, 1 3's, 1 2's, 0 everything else.


    Hope this helps some
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  4. #4
    Addicted Member Rassis's Avatar
    Join Date
    Jun 2004
    Location
    Lisbon
    Posts
    248

    Re: Repeated numbers in a sequence

    Jemidiah,

    Great! I had no idea.
    I just wonder how to modify the expression: Int(n \ (10k)) Mod 10, in order to be coded in Excel. Do you know how to do it? Much obliged.
    ...este projecto dos Deuses que os homens teimam em arruinar...

  5. #5
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: Repeated numbers in a sequence

    I actually got to thinking about that part, and it's a bit redundant. In VB the \ operator as opposed to the / operator means integer division, or x \ y = Int(x / y), and Int(x \ y) = x \ y = Int(x / y). Sorry for taking so long to reply, didn't check that email account
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  6. #6
    Addicted Member Rassis's Avatar
    Join Date
    Jun 2004
    Location
    Lisbon
    Posts
    248

    Re: Repeated numbers in a sequence

    Quote Originally Posted by jemidiah
    I actually got to thinking about that part, and it's a bit redundant. In VB the \ operator as opposed to the / operator means integer division, or x \ y = Int(x / y), and Int(x \ y) = x \ y = Int(x / y). Sorry for taking so long to reply, didn't check that email account
    "Better late than never"! Thank you so much Jemidiah and have a nice time.
    ...este projecto dos Deuses que os homens teimam em arruinar...

  7. #7
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Repeated numbers in a sequence

    Incidentally, if you don't need to even bother with what the numbers are, then a simple start check would be to see if the number is greater than 9876543210. If so, then you have to have at least one repeat.

    zaza

  8. #8
    Addicted Member Rassis's Avatar
    Join Date
    Jun 2004
    Location
    Lisbon
    Posts
    248

    Re: Repeated numbers in a sequence

    I finally managed to code the problem in Excel and I would like to share the solution with whom might be interested. The application returns the answer up to 9 digits. For greater numbers applies what Zaza said in her last post.

    Have fun.
    Attached Files Attached Files
    Last edited by Rassis; Nov 16th, 2005 at 01:36 PM.
    ...este projecto dos Deuses que os homens teimam em arruinar...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width