how to calculate nth root of a very very big integer?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • khosrow
    New Member
    • Aug 2007
    • 9

    how to calculate nth root of a very very big integer?

    I want to calculate the nth root of an integer which is so big that can not even saved in unsigned long long. I've found a way to calculate the 2nd root but it can not be used for other. (I can read the number as a string or an array of char).
    I wonder if you can tell me any method to calculate it without doing any thing to the whole number(I mean I can't multiply, add,... the whole number but i can do it with a part of the number, you can see http://www.bbc.co.uk/dna/h2g2/A827453 to see the way for squar root).
    please help soon i need it NOW!
  • Meetee
    Recognized Expert Contributor
    • Dec 2006
    • 928

    #2
    Originally posted by khosrow
    I want to calculate the nth root of an integer which is so big that can not even saved in unsigned long long. I've found a way to calculate the 2nd root but it can not be used for other. (I can read the number as a string or an array of char).
    I wonder if you can tell me any method to calculate it without doing any thing to the whole number(I mean I can't multiply, add,... the whole number but i can do it with a part of the number, you can see http://www.bbc.co.uk/dna/h2g2/A827453 to see the way for squar root).
    please help soon i need it NOW!
    Kindly read this

    This is purely calculative method. Have you done any coding on this problem? Can you paste it here?

    Regards

    Comment

    • khosrow
      New Member
      • Aug 2007
      • 9

      #3
      Originally posted by zodilla58
      Kindly read this

      This is purely calculative method. Have you done any coding on this problem? Can you paste it here?

      Regards
      I've did it for the squar root as described in that link. but i need for any root not just 2nd root.

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Why don't you just create a class that can deal with a number of the size you have and perform basic operations (+, -, / and *) and then you will be able to calculate the answer.

        Alternitively reverse the operation if

        ROOT = pow(NUMBER, 1/N)

        then

        pow(ROOT, N) = NUMBER

        Assuming positive and non-zero NUMBER and N and that N is an integer then 1 <= ROOT <= NUMBER

        pow(ROOT, N) is easier to calculate than pow(NUMBER, 1/N) since it is just multilication.

        Take a high guess and a low guess at the answer and use a binary chop to itterate to obtain the answer.

        Comment

        • Meetee
          Recognized Expert Contributor
          • Dec 2006
          • 928

          #5
          Originally posted by khosrow
          I've did it for the squar root as described in that link. but i need for any root not just 2nd root.

          Here there is a same problem discussed. Hope it helps.

          Regards

          Comment

          • khosrow
            New Member
            • Aug 2007
            • 9

            #6
            Originally posted by Banfa
            Why don't you just create a class that can deal with a number of the size you have and perform basic operations (+, -, / and *) and then you will be able to calculate the answer.

            Alternitively reverse the operation if

            ROOT = pow(NUMBER, 1/N)

            then

            pow(ROOT, N) = NUMBER

            Assuming positive and non-zero NUMBER and N and that N is an integer then 1 <= ROOT <= NUMBER

            pow(ROOT, N) is easier to calculate than pow(NUMBER, 1/N) since it is just multilication.

            Take a high guess and a low guess at the answer and use a binary chop to itterate to obtain the answer.
            I didn't got it excatly. if i use such classes i will get time limit.
            as they said there's a very simple way to do it (i'm at 2nd grade of highschool so simple for me means really easy). i want a way that i can find the answer digit by digit, i can't count on whole number.

            Comment

            • khosrow
              New Member
              • Aug 2007
              • 9

              #7
              Originally posted by zodilla58
              http://www.thescripts.com/forum/thre...3044-1-10.html
              Here there is a same problem discussed. Hope it helps.

              Regards
              I've seen that before, but it needs to be able to do mathematical work on the number(as I understood), just have a look at that link and you'll understand what i mean.

              thanks for giving me your time.

              Comment

              • Banfa
                Recognized Expert Expert
                • Feb 2006
                • 9067

                #8
                Originally posted by khosrow
                I didn't got it excatly. if i use such classes i will get time limit.
                as they said there's a very simple way to do it (i'm at 2nd grade of highschool so simple for me means really easy). i want a way that i can find the answer digit by digit, i can't count on whole number.
                There is no digit by digit answer to a power problem which is why I suggested you reduced it to a multiplication problem by reversing the equation which does have a digit by digit solution.

                Comment

                • khosrow
                  New Member
                  • Aug 2007
                  • 9

                  #9
                  Originally posted by Banfa
                  There is no digit by digit answer to a power problem which is why I suggested you reduced it to a multiplication problem by reversing the equation which does have a digit by digit solution.
                  I guess I will have to use that in the end. but i'm still surprised to have such a problem as the olympiad project which requires no special algorithm.
                  how ever great thanks for spending your time on my question and wish you the best.
                  Khosrow A.Shahi

                  Comment

                  Working...