05-09-2014 10:31 AM
Thanks crossrulz but how do I compute the value of e to 1000 decimal places in LabVIEW? This is where I have trouble and hence unable to proceed.
05-09-2014 10:36 AM
Get the definition of e here:Euler's number to 10,000 digits
05-09-2014 10:58 AM
Or you can use a Taylor Series. More specifically, the Maclaurin series for e^x is SUM( x^n / n! ) for n=1 to infinity.
so for e, use e^1 and that'd be
SUM( 1^n / n! ) which is: 1 + 1 + 1/2 + 1/6 + 1/24 + ...
You'll have to do most of the addition in strings because you'll be calculating out to 1000 digits and the double precision format can only hold about 15 digits past the decimal.
05-09-2014 04:11 PM
I have now done all questions except question 1. Even after getting info from community members and trying for the past 4 hours, I am unable to do it. Please understand that this problem is too difficult for me to do, so I am giving up. If anyone has the solution vi, please kindly provide.
I have already posted the VIs that I could do which shows that I tried on my own before asking here. I think it is better now to look into a working solution and understand the code than to give up.
05-09-2014 05:02 PM
It's a fair bit of effort to code this, so I doubt anyone is going to hand you the solution unless they are REALLY interested in the problem.
Let's simplify it- forget the part about the sum of the digits, the harder part is calculating e to a high numbrt of digits so let's focus on that. James has already nailed the method- you need to write your own routines to do the math. You need to implement add, multiply and divide functions that can work on numbers represented as strings in order to do the calculations for the taylor series he mentioned.
Build it up. Start with an add function- think about how you add two numbers, digit by digit and carrying the overflows, and come up with an algorithm that copies it. You'll need a loop to iterate over the digits and a shift register to pass the carries. Just have a crack at the add function. If you can do that much, you're well on the way to cracking the whole thing.
05-09-2014 05:08 PM
Here's a link to an example that multiplies 2 integers the way ToeCutter mentioned. It might work as a starting point.
Just for reference, which Euler Problem is this?
https://decibel.ni.com/content/docs/DOC-34858
05-09-2014 05:33 PM
Question 1 is not found in Project euler site. I got it from other sites that do codes using java, c++, python etc. I was trying to code them in LabVIEW. Thankyou very much for the link James. Ok I will try again.
05-09-2014 08:21 PM
I think there was a coding challenge several years ago which addressed the large numbers of digits arithmetic issue. A search may find some useful code or ideas.
Lynn
05-10-2014 04:30 AM
I have done question 1 and got the result as 2147483647. Is this correct ?
05-10-2014 05:53 AM
Please can anyone check wether the final result for question 1 is 2147483647 or not?
Thanks