As you may have noticed there has been a little challenge going on to write code, in the language of your choice, that can calculate the first Fibonacci number with one million decimal digits. That is to say the 4784969th Fibonacci number.
There are a few requirements for the challenge:
1) To output the one million digit result as a string of decimal digits.
2) The use of libraries, modules, extensions that are not supplied as a standard part of the language is not allowed.
3) Whilst solutions written in languages that only have closed source, proprietary implementations are welcome they will not be added to my Million Digit Challenge Github repository.
4) Must run on the Raspberry Pi.
5) Perhaps some other rules I have forgotten!
Note that the challenge was not intended as a benchmark and performance is not the most significant criteria. The intention was simply to demonstrate how easy it is to create a solution in various languages, how elegant and readable the solutions are for others. But of course, now the Pi 4 is out I'm curious as to how it compares performance wise.
Since the challenge was thrown down at the beginning of the year solutions have been presented in 18 different languages. Sometimes multiple solutions in the same language, sometimes multiple dialects of the same language.
The challenge forum thread has been continuing here: https://www.raspberrypi.org/forums/view ... &start=600
The Challenge github repository is here: https://github.com/ZiCog/fibo_4784969
I put up an online Fibonacci number calculator here: https://otaniemi.conveqs.fi:3000/public/fibo.html As far as I know it is the only such calculator online that can produce a million digit result. I'm still in two minds as to whether it qualifies for the challenge because whilst the fibo algorithm is written in JS the big number arithmetic is my C++ big integer class compiled to Web Assembly. Still, it's pretty impressive to be able to do that in the browser itself.
So how about it, any kind and curious souls up to running any of those codes on a Pi 4 and letting us know the timings?
We simply use the "time" command to do that. For example (on my PC):
Code: Select all
$ time node hfibo.js | head -c 32; time node hfibo.js | tail -c 32 10727395641800477229364813596225 real 1m16.210s user 1m15.141s sys 0m0.156s 4856539211500699706378405156269 real 1m15.948s user 1m15.219s sys 0m0.156s
Oh, and results from anyone with a 64 bit OS on the Pi 4 would be interesting as well.