10-15-2023 08:09 AM
Hi guys
I am trying to add two big integers (like in Fibonacci sequence). Big, means much larger than I64. I wrote a vi, attached here, and I am wondering if it can be done better, aka faster (@Altenbach: if you provide a solution please add a ELI5 🙂 )
To explain, I am putting the numbers in arrays of U8 and do the addition as in elementary school.
If you have ideas how to do it faster pls let me know.
Regards
Solved! Go to Solution.
10-15-2023 09:08 AM
I once found this on the web.
10-15-2023 10:26 AM
@nitad54449 wrote:
Hi guys
I am trying to add two big integers (like in Fibonacci sequence). Big, means much larger than I64. I wrote a vi, attached here, and I am wondering if it can be done better, aka faster (@Altenbach: if you provide a solution please add a ELI5 🙂 )
If you have ideas how to do it faster pls let me know.
There are several overcomplications in your code. Maybe you can have a look at my primitive factorial. The subVIs could easily be expanded to add two numbers.
One possibility to improve speed would be to use integers with more bits, each containing several digits. (e.g. base 10000000 instead of base 10)
10-15-2023 10:53 AM - edited 10-15-2023 10:56 AM
A quick analysis of your VI:
Here's what I might do. No guaranteed that it's faster... 😄
10-15-2023 11:09 AM
Hi Christian
I forgot to mention that the first number (array) is the same length as the second or, at most, one digit larger. I will take a look at your code and check it is faster,
thanks
10-15-2023 11:21 AM
Hi CA
after some tests, your vi is 3 times faster than mine !
thanks
10-15-2023 11:27 AM
10-15-2023 11:37 AM
thanks
i tried the add and it does not work properly
N
10-15-2023 11:39 AM
be my guest 🙂
I am trying to find (just for fun) big Fibonacci numbers.
The 10^6 number has 200K digits, it takes 400 seconds with my code.
N
10-15-2023 12:38 PM
Here's a quick draft to generate the elements if the Fibonacci sequence. A google search for element 1000 shows the the result is correct.
As mentioned, it could still be sped up by orders of magnitude... 😄