473,586 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

9 New Member
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 8249
Meetee
931 Recognized Expert Moderator Contributor
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
khosrow
9 New Member
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 Recognized Expert Moderator Expert
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 Recognized Expert Moderator Contributor
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
khosrow
9 New Member
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
khosrow
9 New Member
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 Recognized Expert Moderator Expert
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
khosrow
9 New Member
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
2668
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 to program c++ (3 month ago), so i'm very lost with this problem. I have been making a test i Visual Basic and one Borland C++, but the
4
8679
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 together and the square root of the product is returned and displayed for the user. The function should return a double. Hint: If you multiply an...
1
13594
by: sg_s123 | last post by:
============================================================================ 02-Feb-04 03-Feb-04 Staff Staff 0800hr- 1300hr- 1700hr- 1900hr- 0800hr- 1300hr- 1700hr- 1900hr- Number Name 1200hr 1700hr 1900hr 2200hr 1200hr 1700hr 1900hr 2200hr ============================================================================...
15
4143
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: struct node { struct node *next; void *data; };
6
4129
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 end is found is less efficient than using sizeof operator , since size of the array is completely determined at compile time. i don't quite...
12
14478
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, that has limited width but multiple lines. Currently I am using the left$() function to trim the text to a standard number of characters. I want a...
1
8749
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 program should warn the user if the
6
2319
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
3412
by: lenygold via DBMonster.com | last post by:
Here is my input table: TUE MON ----------- ----------- 2 - - 25 27 - - 48 50 - - 78
0
7912
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8216
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.