473,385 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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!
Aug 2 '07 #1
8 8211
Meetee
931 Expert Mod 512MB
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
Aug 2 '07 #2
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.
Aug 2 '07 #3
Banfa
9,065 Expert Mod 8TB
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.
Aug 2 '07 #4
Meetee
931 Expert Mod 512MB
I've did it for the squar root as described in that link. but i need for any root not just 2nd root.
http://www.thescripts.com/forum/thre...3044-1-10.html
Here there is a same problem discussed. Hope it helps.

Regards
Aug 2 '07 #5
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.
Aug 2 '07 #6
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.
Aug 2 '07 #7
Banfa
9,065 Expert Mod 8TB
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.
Aug 2 '07 #8
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
Aug 2 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Jepsensen | last post by:
Dear Everybody. I got a problem with my cpp code. I'm trying to calculate a very simple Discrete Cosine Transform (DCT), but my c++ code seams to calculate a wrong result. I have just started...
4
by: cplusplus | last post by:
Hello, I have newbie question. I'm stuck on this current assignment. Write a program that prompts the user for two integer values, passes the values to a function where they are multiplied...
1
by: sg_s123 | last post by:
============================================================================ 02-Feb-04 03-Feb-04 Staff Staff 0800hr- 1300hr- 1700hr- 1900hr- 0800hr- 1300hr- 1700hr- 1900hr- Number...
15
by: Stig Brautaset | last post by:
Hi group, I'm playing with a little generic linked list/stack library, and have a little problem with the interface of the pop() function. If I used a struct like this it would be simple: ...
6
by: Herrcho | last post by:
in K&R Chapter 6.3 it mentions two methods to calculate NKEYS. and points out the first one which is to terminate the list of initializers with a null pointer, then loop along keytab until the...
12
by: paii, Ron | last post by:
Sorry about that last one. Does anyone know how to calculate the width a string of text for given Font name and size? I want to buildup a block of text strings to display in a unbound control,...
1
by: Tin | last post by:
Dear Sir/Madam, I have one assignment , which need me to write a program to calculate the factorial of an integer, then press the button that would display the result in a label.3 & the...
6
by: vbwire | last post by:
i use vb 6.0 Option Explicit Dim Error As Double Dim x As Integer Dim y As Double Dim z As Integer
6
by: lenygold via DBMonster.com | last post by:
Here is my input table: TUE MON ----------- ----------- 2 - - 25 27 - - 48 50 - - 78
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.